<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# LANGUAGE Trustworthy #-}</span><span>
</span><span id="line-2"></span><span class="hs-pragma">{-# LANGUAGE CPP
           , NoImplicitPrelude
           , BangPatterns
  #-}</span><span>
</span><span id="line-6"></span><span class="hs-pragma">{-# OPTIONS_GHC -Wno-identities #-}</span><span>
</span><span id="line-7"></span><span class="hs-comment">-- Whether there are identities depends on the platform</span><span>
</span><span id="line-8"></span><span class="hs-pragma">{-# OPTIONS_HADDOCK not-home #-}</span><span>
</span><span id="line-9"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-10"></span><span class="hs-comment">-- |</span><span>
</span><span id="line-11"></span><span class="hs-comment">-- Module      :  GHC.IO.FD</span><span>
</span><span id="line-12"></span><span class="hs-comment">-- Copyright   :  (c) The University of Glasgow, 1994-2008</span><span>
</span><span id="line-13"></span><span class="hs-comment">-- License     :  see libraries/base/LICENSE</span><span>
</span><span id="line-14"></span><span class="hs-comment">--</span><span>
</span><span id="line-15"></span><span class="hs-comment">-- Maintainer  :  libraries@haskell.org</span><span>
</span><span id="line-16"></span><span class="hs-comment">-- Stability   :  internal</span><span>
</span><span id="line-17"></span><span class="hs-comment">-- Portability :  non-portable</span><span>
</span><span id="line-18"></span><span class="hs-comment">--</span><span>
</span><span id="line-19"></span><span class="hs-comment">-- Raw read/write operations on file descriptors</span><span>
</span><span id="line-20"></span><span class="hs-comment">--</span><span>
</span><span id="line-21"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-22"></span><span>
</span><span id="line-23"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">GHC.IO.FD</span><span> </span><span class="hs-special">(</span><span>
</span><span id="line-24"></span><span>        </span><span class="annot"><a href="GHC.IO.FD.html#FD"><span class="hs-identifier">FD</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span>
</span><span id="line-25"></span><span>        </span><span class="annot"><a href="GHC.IO.FD.html#openFile"><span class="hs-identifier">openFile</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.FD.html#mkFD"><span class="hs-identifier">mkFD</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.FD.html#release"><span class="hs-identifier">release</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-26"></span><span>        </span><span class="annot"><a href="GHC.IO.FD.html#setNonBlockingMode"><span class="hs-identifier">setNonBlockingMode</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-27"></span><span>        </span><span class="annot"><a href="GHC.IO.FD.html#readRawBufferPtr"><span class="hs-identifier">readRawBufferPtr</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.FD.html#readRawBufferPtrNoBlock"><span class="hs-identifier">readRawBufferPtrNoBlock</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.FD.html#writeRawBufferPtr"><span class="hs-identifier">writeRawBufferPtr</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-28"></span><span>        </span><span class="annot"><a href="GHC.IO.FD.html#stdin"><span class="hs-identifier">stdin</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.FD.html#stdout"><span class="hs-identifier">stdout</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.FD.html#stderr"><span class="hs-identifier">stderr</span></a></span><span>
</span><span id="line-29"></span><span>    </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-30"></span><span>
</span><span id="line-31"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Base.html"><span class="hs-identifier">GHC.Base</span></a></span><span>
</span><span id="line-32"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Num.html"><span class="hs-identifier">GHC.Num</span></a></span><span>
</span><span id="line-33"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Real.html"><span class="hs-identifier">GHC.Real</span></a></span><span>
</span><span id="line-34"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Show.html"><span class="hs-identifier">GHC.Show</span></a></span><span>
</span><span id="line-35"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Enum.html"><span class="hs-identifier">GHC.Enum</span></a></span><span>
</span><span id="line-36"></span><span>
</span><span id="line-37"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.IO.html"><span class="hs-identifier">GHC.IO</span></a></span><span>
</span><span id="line-38"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.IO.IOMode.html"><span class="hs-identifier">GHC.IO.IOMode</span></a></span><span>
</span><span id="line-39"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.IO.Buffer.html"><span class="hs-identifier">GHC.IO.Buffer</span></a></span><span>
</span><span id="line-40"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.IO.BufferedIO.html"><span class="hs-identifier">GHC.IO.BufferedIO</span></a></span><span>
</span><span id="line-41"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="GHC.IO.Device.html"><span class="hs-identifier">GHC.IO.Device</span></a></span><span>
</span><span id="line-42"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.IO.Device.html"><span class="hs-identifier">GHC.IO.Device</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.IO.Device.html#SeekMode"><span class="hs-identifier">SeekMode</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Device.html#IODeviceType"><span class="hs-identifier">IODeviceType</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-43"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Conc.IO.html"><span class="hs-identifier">GHC.Conc.IO</span></a></span><span>
</span><span id="line-44"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.IO.Exception.html"><span class="hs-identifier">GHC.IO.Exception</span></a></span><span class="hs-cpp">
#if defined(mingw32_HOST_OS)
</span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Windows.html"><span class="hs-identifier">GHC.Windows</span></a></span><span>
</span><span id="line-47"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Data.Bool.html"><span class="hs-identifier">Data.Bool</span></a></span><span>
</span><span id="line-48"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.IO.SubSystem.html"><span class="hs-identifier">GHC.IO.SubSystem</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.IO.SubSystem.html#%3C%21%3E"><span class="hs-operator">(&lt;!&gt;)</span></a></span><span class="hs-special">)</span><span class="hs-cpp">
#endif
</span><span>
</span><span id="line-51"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Foreign.html"><span class="hs-identifier">Foreign</span></a></span><span>
</span><span id="line-52"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Foreign.C.html"><span class="hs-identifier">Foreign.C</span></a></span><span>
</span><span id="line-53"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="System.Posix.Internals.html"><span class="hs-identifier">System.Posix.Internals</span></a></span><span>
</span><span id="line-54"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="System.Posix.Internals.html"><span class="hs-identifier">System.Posix.Internals</span></a></span><span> </span><span class="hs-keyword">hiding</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="System.Posix.Internals.html#FD"><span class="hs-identifier">FD</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="System.Posix.Internals.html#setEcho"><span class="hs-identifier">setEcho</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="System.Posix.Internals.html#getEcho"><span class="hs-identifier">getEcho</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-55"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="System.Posix.Types.html"><span class="hs-identifier">System.Posix.Types</span></a></span><span class="hs-cpp">

#if defined(mingw32_HOST_OS)
</span><span class="hs-cpp"># if defined(i386_HOST_ARCH)
</span><span class="hs-cpp">#  define WINDOWS_CCONV stdcall
</span><span class="hs-cpp"># elif defined(x86_64_HOST_ARCH)
</span><span class="hs-cpp">#  define WINDOWS_CCONV ccall
</span><span class="hs-cpp"># else
</span><span class="hs-cpp">#  error Unknown mingw32 arch
</span><span class="hs-cpp"># endif
</span><span class="hs-cpp">#endif
</span><span>
</span><span id="line-67"></span><span class="annot"><a href="GHC.IO.FD.html#c_DEBUG_DUMP"><span class="hs-identifier hs-type">c_DEBUG_DUMP</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Bool"><span class="hs-identifier hs-type">Bool</span></a></span><span>
</span><span id="line-68"></span><span id="c_DEBUG_DUMP"><span class="annot"><span class="annottext">c_DEBUG_DUMP :: Bool
</span><a href="GHC.IO.FD.html#c_DEBUG_DUMP"><span class="hs-identifier hs-var hs-var">c_DEBUG_DUMP</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../ghc-prim/src/GHC.Types.html#False"><span class="hs-identifier hs-var">False</span></a></span><span>
</span><span id="line-69"></span><span>
</span><span id="line-70"></span><span class="hs-comment">-- Darwin limits the length of writes to 2GB. See #17414.</span><span>
</span><span id="line-71"></span><span class="hs-comment">-- Moreover, Linux will only transfer up to 0x7ffff000 and interpreting the</span><span>
</span><span id="line-72"></span><span class="hs-comment">-- result of write/read is tricky above 2GB due to its signed type. For</span><span>
</span><span id="line-73"></span><span class="hs-comment">-- simplicity we therefore clamp on all platforms.</span><span>
</span><span id="line-74"></span><span class="annot"><a href="GHC.IO.FD.html#clampWriteSize"><span class="hs-identifier hs-type">clampWriteSize</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.FD.html#clampReadSize"><span class="hs-identifier hs-type">clampReadSize</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span>
</span><span id="line-75"></span><span id="clampWriteSize"><span class="annot"><span class="annottext">clampWriteSize :: Int -&gt; Int
</span><a href="GHC.IO.FD.html#clampWriteSize"><span class="hs-identifier hs-var hs-var">clampWriteSize</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Ord a =&gt; a -&gt; a -&gt; a
</span><a href="../../ghc-prim/src/GHC.Classes.html#min"><span class="hs-identifier hs-var">min</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0x7ffff000</span></span><span>
</span><span id="line-76"></span><span id="clampReadSize"><span class="annot"><span class="annottext">clampReadSize :: Int -&gt; Int
</span><a href="GHC.IO.FD.html#clampReadSize"><span class="hs-identifier hs-var hs-var">clampReadSize</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Ord a =&gt; a -&gt; a -&gt; a
</span><a href="../../ghc-prim/src/GHC.Classes.html#min"><span class="hs-identifier hs-var">min</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0x7ffff000</span></span><span>
</span><span id="line-77"></span><span>
</span><span id="line-78"></span><span class="hs-comment">-- -----------------------------------------------------------------------------</span><span>
</span><span id="line-79"></span><span class="hs-comment">-- The file-descriptor IO device</span><span>
</span><span id="line-80"></span><span>
</span><span id="line-81"></span><span class="hs-keyword">data</span><span> </span><span id="FD"><span class="annot"><a href="GHC.IO.FD.html#FD"><span class="hs-identifier hs-var">FD</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="FD"><span class="annot"><a href="GHC.IO.FD.html#FD"><span class="hs-identifier hs-var">FD</span></a></span></span><span> </span><span class="hs-special">{</span><span>
</span><span id="line-82"></span><span>  </span><span id="fdFD"><span class="annot"><span class="annottext">FD -&gt; CInt
</span><a href="GHC.IO.FD.html#fdFD"><span class="hs-identifier hs-var hs-var">fdFD</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-pragma">{-# UNPACK</span><span> </span><span class="hs-pragma">#-}</span><span> </span><span class="hs-glyph">!</span><span class="annot"><a href="Foreign.C.Types.html#CInt"><span class="hs-identifier hs-type">CInt</span></a></span><span class="hs-special">,</span><span class="hs-cpp">
#if defined(mingw32_HOST_OS)
</span><span>  </span><span class="hs-comment">-- On Windows, a socket file descriptor needs to be read and written</span><span>
</span><span id="line-85"></span><span>  </span><span class="hs-comment">-- using different functions (send/recv).</span><span>
</span><span id="line-86"></span><span>  </span><span id="fdIsSocket_"><span class="annot"><span class="annottext">FD -&gt; Int
</span><a href="GHC.IO.FD.html#fdIsSocket_"><span class="hs-identifier hs-var hs-var">fdIsSocket_</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-pragma">{-# UNPACK</span><span> </span><span class="hs-pragma">#-}</span><span> </span><span class="hs-glyph">!</span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span class="hs-cpp">
#else
</span><span>  </span><span class="hs-comment">-- On Unix we need to know whether this FD has O_NONBLOCK set.</span><span>
</span><span id="line-89"></span><span>  </span><span class="hs-comment">-- If it has, then we can use more efficient routines to read/write to it.</span><span>
</span><span id="line-90"></span><span>  </span><span class="hs-comment">-- It is always safe for this to be off.</span><span>
</span><span id="line-91"></span><span>  </span><span class="hs-identifier">fdIsNonBlocking</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-pragma">{-# UNPACK</span><span> </span><span class="hs-pragma">#-}</span><span> </span><span class="hs-glyph">!</span><span class="hs-identifier">Int</span><span class="hs-cpp">
#endif
</span><span> </span><span class="hs-special">}</span><span class="hs-cpp">

#if defined(mingw32_HOST_OS)
</span><span class="annot"><a href="GHC.IO.FD.html#fdIsSocket"><span class="hs-identifier hs-type">fdIsSocket</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.FD.html#FD"><span class="hs-identifier hs-type">FD</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Bool"><span class="hs-identifier hs-type">Bool</span></a></span><span>
</span><span id="line-97"></span><span id="fdIsSocket"><span class="annot"><span class="annottext">fdIsSocket :: FD -&gt; Bool
</span><a href="GHC.IO.FD.html#fdIsSocket"><span class="hs-identifier hs-var hs-var">fdIsSocket</span></a></span></span><span> </span><span id="local-6989586621679555174"><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679555174"><span class="hs-identifier hs-var">fd</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FD -&gt; Int
</span><a href="GHC.IO.FD.html#fdIsSocket_"><span class="hs-identifier hs-var hs-var">fdIsSocket_</span></a></span><span> </span><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679555174"><span class="hs-identifier hs-var">fd</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%2F%3D"><span class="hs-operator hs-var">/=</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span class="hs-cpp">
#endif
</span><span>
</span><span id="line-100"></span><span class="hs-comment">-- | @since 4.1.0.0</span><span>
</span><span id="line-101"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621679555168"><span id="local-6989586621679555171"><span class="annot"><a href="GHC.Show.html#Show"><span class="hs-identifier hs-type">Show</span></a></span><span> </span><span class="annot"><a href="GHC.IO.FD.html#FD"><span class="hs-identifier hs-type">FD</span></a></span></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-102"></span><span>  </span><span id="local-6989586621679555164"><span class="annot"><span class="annottext">show :: FD -&gt; String
</span><a href="GHC.Show.html#show"><span class="hs-identifier hs-var hs-var hs-var hs-var">show</span></a></span></span><span> </span><span id="local-6989586621679555162"><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679555162"><span class="hs-identifier hs-var">fd</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CInt -&gt; String
forall a. Show a =&gt; a -&gt; String
</span><a href="GHC.Show.html#show"><span class="hs-identifier hs-var">show</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FD -&gt; CInt
</span><a href="GHC.IO.FD.html#fdFD"><span class="hs-identifier hs-var hs-var">fdFD</span></a></span><span> </span><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679555162"><span class="hs-identifier hs-var">fd</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-103"></span><span>
</span><span id="line-104"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="GHC.IO.FD.html#ifSupported"><span class="hs-pragma hs-type">ifSupported</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-105"></span><span id="local-6989586621679555502"><span class="annot"><a href="GHC.IO.FD.html#ifSupported"><span class="hs-identifier hs-type">ifSupported</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679555502"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679555502"><span class="hs-identifier hs-type">a</span></a></span></span><span class="hs-cpp">
#if defined(mingw32_HOST_OS)
</span><span id="ifSupported"><span class="annot"><span class="annottext">ifSupported :: forall a. String -&gt; a -&gt; a
</span><a href="GHC.IO.FD.html#ifSupported"><span class="hs-identifier hs-var hs-var">ifSupported</span></a></span></span><span> </span><span id="local-6989586621679555158"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679555158"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span id="local-6989586621679555157"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679555157"><span class="hs-identifier hs-var">a</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679555157"><span class="hs-identifier hs-var">a</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; a -&gt; a
forall a. a -&gt; a -&gt; a
</span><a href="GHC.IO.SubSystem.html#%3C%21%3E"><span class="hs-operator hs-var">&lt;!&gt;</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; a
forall a. HasCallStack =&gt; String -&gt; a
</span><a href="GHC.Err.html#error"><span class="hs-identifier hs-var">error</span></a></span><span> </span><span class="annot"><span class="annottext">(String -&gt; a) -&gt; String -&gt; a
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;FD:&quot;</span></span><span> </span><span class="annot"><span class="annottext">String -&gt; ShowS
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679555158"><span class="hs-identifier hs-var">s</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; ShowS
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot; not supported&quot;</span></span><span class="hs-special">)</span><span class="hs-cpp">
#else
</span><span class="hs-identifier">ifSupported</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">id</span><span class="hs-cpp">
#endif
</span><span>
</span><span id="line-112"></span><span class="hs-comment">-- | @since 4.1.0.0</span><span>
</span><span id="line-113"></span><span class="hs-keyword">instance</span><span> </span><span class="annot"><a href="GHC.IO.Device.html#RawIO"><span class="hs-identifier hs-type">GHC.IO.Device.RawIO</span></a></span><span> </span><span class="annot"><a href="GHC.IO.FD.html#FD"><span class="hs-identifier hs-type">FD</span></a></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-114"></span><span>  </span><span id="local-6989586621679555150"><span class="annot"><span class="annottext">read :: FD -&gt; Ptr Word8 -&gt; Word64 -&gt; Int -&gt; IO Int
</span><a href="GHC.IO.Device.html#read"><span class="hs-identifier hs-var hs-var hs-var hs-var">read</span></a></span></span><span>             </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String
-&gt; (FD -&gt; Ptr Word8 -&gt; Word64 -&gt; Int -&gt; IO Int)
-&gt; FD
-&gt; Ptr Word8
-&gt; Word64
-&gt; Int
-&gt; IO Int
forall a. String -&gt; a -&gt; a
</span><a href="GHC.IO.FD.html#ifSupported"><span class="hs-identifier hs-var">ifSupported</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;fdRead&quot;</span></span><span> </span><span class="annot"><span class="annottext">FD -&gt; Ptr Word8 -&gt; Word64 -&gt; Int -&gt; IO Int
</span><a href="GHC.IO.FD.html#fdRead"><span class="hs-identifier hs-var">fdRead</span></a></span><span>
</span><span id="line-115"></span><span>  </span><span id="local-6989586621679555147"><span class="annot"><span class="annottext">readNonBlocking :: FD -&gt; Ptr Word8 -&gt; Word64 -&gt; Int -&gt; IO (Maybe Int)
</span><a href="GHC.IO.Device.html#readNonBlocking"><span class="hs-identifier hs-var hs-var hs-var hs-var">readNonBlocking</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String
-&gt; (FD -&gt; Ptr Word8 -&gt; Word64 -&gt; Int -&gt; IO (Maybe Int))
-&gt; FD
-&gt; Ptr Word8
-&gt; Word64
-&gt; Int
-&gt; IO (Maybe Int)
forall a. String -&gt; a -&gt; a
</span><a href="GHC.IO.FD.html#ifSupported"><span class="hs-identifier hs-var">ifSupported</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;fdReadNonBlocking&quot;</span></span><span> </span><span class="annot"><span class="annottext">FD -&gt; Ptr Word8 -&gt; Word64 -&gt; Int -&gt; IO (Maybe Int)
</span><a href="GHC.IO.FD.html#fdReadNonBlocking"><span class="hs-identifier hs-var">fdReadNonBlocking</span></a></span><span>
</span><span id="line-116"></span><span>  </span><span id="local-6989586621679555144"><span class="annot"><span class="annottext">write :: FD -&gt; Ptr Word8 -&gt; Word64 -&gt; Int -&gt; IO ()
</span><a href="GHC.IO.Device.html#write"><span class="hs-identifier hs-var hs-var hs-var hs-var">write</span></a></span></span><span>            </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String
-&gt; (FD -&gt; Ptr Word8 -&gt; Word64 -&gt; Int -&gt; IO ())
-&gt; FD
-&gt; Ptr Word8
-&gt; Word64
-&gt; Int
-&gt; IO ()
forall a. String -&gt; a -&gt; a
</span><a href="GHC.IO.FD.html#ifSupported"><span class="hs-identifier hs-var">ifSupported</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;fdWrite&quot;</span></span><span> </span><span class="annot"><span class="annottext">FD -&gt; Ptr Word8 -&gt; Word64 -&gt; Int -&gt; IO ()
</span><a href="GHC.IO.FD.html#fdWrite"><span class="hs-identifier hs-var">fdWrite</span></a></span><span>
</span><span id="line-117"></span><span>  </span><span id="local-6989586621679555141"><span class="annot"><span class="annottext">writeNonBlocking :: FD -&gt; Ptr Word8 -&gt; Word64 -&gt; Int -&gt; IO Int
</span><a href="GHC.IO.Device.html#writeNonBlocking"><span class="hs-identifier hs-var hs-var hs-var hs-var">writeNonBlocking</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String
-&gt; (FD -&gt; Ptr Word8 -&gt; Word64 -&gt; Int -&gt; IO Int)
-&gt; FD
-&gt; Ptr Word8
-&gt; Word64
-&gt; Int
-&gt; IO Int
forall a. String -&gt; a -&gt; a
</span><a href="GHC.IO.FD.html#ifSupported"><span class="hs-identifier hs-var">ifSupported</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;fdWriteNonBlocking&quot;</span></span><span> </span><span class="annot"><span class="annottext">FD -&gt; Ptr Word8 -&gt; Word64 -&gt; Int -&gt; IO Int
</span><a href="GHC.IO.FD.html#fdWriteNonBlocking"><span class="hs-identifier hs-var">fdWriteNonBlocking</span></a></span><span>
</span><span id="line-118"></span><span>
</span><span id="line-119"></span><span class="hs-comment">-- | @since 4.1.0.0</span><span>
</span><span id="line-120"></span><span class="hs-keyword">instance</span><span> </span><span class="annot"><a href="GHC.IO.Device.html#IODevice"><span class="hs-identifier hs-type">GHC.IO.Device.IODevice</span></a></span><span> </span><span class="annot"><a href="GHC.IO.FD.html#FD"><span class="hs-identifier hs-type">FD</span></a></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-121"></span><span>  </span><span id="local-6989586621679555122"><span class="annot"><span class="annottext">ready :: FD -&gt; Bool -&gt; Int -&gt; IO Bool
</span><a href="GHC.IO.Device.html#ready"><span class="hs-identifier hs-var hs-var hs-var hs-var">ready</span></a></span></span><span>         </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String
-&gt; (FD -&gt; Bool -&gt; Int -&gt; IO Bool) -&gt; FD -&gt; Bool -&gt; Int -&gt; IO Bool
forall a. String -&gt; a -&gt; a
</span><a href="GHC.IO.FD.html#ifSupported"><span class="hs-identifier hs-var">ifSupported</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;ready&quot;</span></span><span> </span><span class="annot"><span class="annottext">FD -&gt; Bool -&gt; Int -&gt; IO Bool
</span><a href="GHC.IO.FD.html#ready"><span class="hs-identifier hs-var">ready</span></a></span><span>
</span><span id="line-122"></span><span>  </span><span id="local-6989586621679555119"><span class="annot"><span class="annottext">close :: FD -&gt; IO ()
</span><a href="GHC.IO.Device.html#close"><span class="hs-identifier hs-var hs-var hs-var hs-var">close</span></a></span></span><span>         </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; (FD -&gt; IO ()) -&gt; FD -&gt; IO ()
forall a. String -&gt; a -&gt; a
</span><a href="GHC.IO.FD.html#ifSupported"><span class="hs-identifier hs-var">ifSupported</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;close&quot;</span></span><span> </span><span class="annot"><span class="annottext">FD -&gt; IO ()
</span><a href="GHC.IO.FD.html#close"><span class="hs-identifier hs-var">close</span></a></span><span>
</span><span id="line-123"></span><span>  </span><span id="local-6989586621679555116"><span class="annot"><span class="annottext">isTerminal :: FD -&gt; IO Bool
</span><a href="GHC.IO.Device.html#isTerminal"><span class="hs-identifier hs-var hs-var hs-var hs-var">isTerminal</span></a></span></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; (FD -&gt; IO Bool) -&gt; FD -&gt; IO Bool
forall a. String -&gt; a -&gt; a
</span><a href="GHC.IO.FD.html#ifSupported"><span class="hs-identifier hs-var">ifSupported</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;isTerm&quot;</span></span><span> </span><span class="annot"><span class="annottext">FD -&gt; IO Bool
</span><a href="GHC.IO.FD.html#isTerminal"><span class="hs-identifier hs-var">isTerminal</span></a></span><span>
</span><span id="line-124"></span><span>  </span><span id="local-6989586621679555113"><span class="annot"><span class="annottext">isSeekable :: FD -&gt; IO Bool
</span><a href="GHC.IO.Device.html#isSeekable"><span class="hs-identifier hs-var hs-var hs-var hs-var">isSeekable</span></a></span></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; (FD -&gt; IO Bool) -&gt; FD -&gt; IO Bool
forall a. String -&gt; a -&gt; a
</span><a href="GHC.IO.FD.html#ifSupported"><span class="hs-identifier hs-var">ifSupported</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;isSeek&quot;</span></span><span> </span><span class="annot"><span class="annottext">FD -&gt; IO Bool
</span><a href="GHC.IO.FD.html#isSeekable"><span class="hs-identifier hs-var">isSeekable</span></a></span><span>
</span><span id="line-125"></span><span>  </span><span id="local-6989586621679555110"><span class="annot"><span class="annottext">seek :: FD -&gt; SeekMode -&gt; Integer -&gt; IO Integer
</span><a href="GHC.IO.Device.html#seek"><span class="hs-identifier hs-var hs-var hs-var hs-var">seek</span></a></span></span><span>          </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String
-&gt; (FD -&gt; SeekMode -&gt; Integer -&gt; IO Integer)
-&gt; FD
-&gt; SeekMode
-&gt; Integer
-&gt; IO Integer
forall a. String -&gt; a -&gt; a
</span><a href="GHC.IO.FD.html#ifSupported"><span class="hs-identifier hs-var">ifSupported</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;seek&quot;</span></span><span> </span><span class="annot"><span class="annottext">FD -&gt; SeekMode -&gt; Integer -&gt; IO Integer
</span><a href="GHC.IO.FD.html#seek"><span class="hs-identifier hs-var">seek</span></a></span><span>
</span><span id="line-126"></span><span>  </span><span id="local-6989586621679555107"><span class="annot"><span class="annottext">tell :: FD -&gt; IO Integer
</span><a href="GHC.IO.Device.html#tell"><span class="hs-identifier hs-var hs-var hs-var hs-var">tell</span></a></span></span><span>          </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; (FD -&gt; IO Integer) -&gt; FD -&gt; IO Integer
forall a. String -&gt; a -&gt; a
</span><a href="GHC.IO.FD.html#ifSupported"><span class="hs-identifier hs-var">ifSupported</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;tell&quot;</span></span><span> </span><span class="annot"><span class="annottext">FD -&gt; IO Integer
</span><a href="GHC.IO.FD.html#tell"><span class="hs-identifier hs-var">tell</span></a></span><span>
</span><span id="line-127"></span><span>  </span><span id="local-6989586621679555104"><span class="annot"><span class="annottext">getSize :: FD -&gt; IO Integer
</span><a href="GHC.IO.Device.html#getSize"><span class="hs-identifier hs-var hs-var hs-var hs-var">getSize</span></a></span></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; (FD -&gt; IO Integer) -&gt; FD -&gt; IO Integer
forall a. String -&gt; a -&gt; a
</span><a href="GHC.IO.FD.html#ifSupported"><span class="hs-identifier hs-var">ifSupported</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;getSize&quot;</span></span><span> </span><span class="annot"><span class="annottext">FD -&gt; IO Integer
</span><a href="GHC.IO.FD.html#getSize"><span class="hs-identifier hs-var">getSize</span></a></span><span>
</span><span id="line-128"></span><span>  </span><span id="local-6989586621679555101"><span class="annot"><span class="annottext">setSize :: FD -&gt; Integer -&gt; IO ()
</span><a href="GHC.IO.Device.html#setSize"><span class="hs-identifier hs-var hs-var hs-var hs-var">setSize</span></a></span></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; (FD -&gt; Integer -&gt; IO ()) -&gt; FD -&gt; Integer -&gt; IO ()
forall a. String -&gt; a -&gt; a
</span><a href="GHC.IO.FD.html#ifSupported"><span class="hs-identifier hs-var">ifSupported</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;setSize&quot;</span></span><span> </span><span class="annot"><span class="annottext">FD -&gt; Integer -&gt; IO ()
</span><a href="GHC.IO.FD.html#setSize"><span class="hs-identifier hs-var">setSize</span></a></span><span>
</span><span id="line-129"></span><span>  </span><span id="local-6989586621679555098"><span class="annot"><span class="annottext">setEcho :: FD -&gt; Bool -&gt; IO ()
</span><a href="GHC.IO.Device.html#setEcho"><span class="hs-identifier hs-var hs-var hs-var hs-var">setEcho</span></a></span></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; (FD -&gt; Bool -&gt; IO ()) -&gt; FD -&gt; Bool -&gt; IO ()
forall a. String -&gt; a -&gt; a
</span><a href="GHC.IO.FD.html#ifSupported"><span class="hs-identifier hs-var">ifSupported</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;setEcho&quot;</span></span><span> </span><span class="annot"><span class="annottext">FD -&gt; Bool -&gt; IO ()
</span><a href="GHC.IO.FD.html#setEcho"><span class="hs-identifier hs-var">setEcho</span></a></span><span>
</span><span id="line-130"></span><span>  </span><span id="local-6989586621679555095"><span class="annot"><span class="annottext">getEcho :: FD -&gt; IO Bool
</span><a href="GHC.IO.Device.html#getEcho"><span class="hs-identifier hs-var hs-var hs-var hs-var">getEcho</span></a></span></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; (FD -&gt; IO Bool) -&gt; FD -&gt; IO Bool
forall a. String -&gt; a -&gt; a
</span><a href="GHC.IO.FD.html#ifSupported"><span class="hs-identifier hs-var">ifSupported</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;getEcho&quot;</span></span><span> </span><span class="annot"><span class="annottext">FD -&gt; IO Bool
</span><a href="GHC.IO.FD.html#getEcho"><span class="hs-identifier hs-var">getEcho</span></a></span><span>
</span><span id="line-131"></span><span>  </span><span id="local-6989586621679555092"><span class="annot"><span class="annottext">setRaw :: FD -&gt; Bool -&gt; IO ()
</span><a href="GHC.IO.Device.html#setRaw"><span class="hs-identifier hs-var hs-var hs-var hs-var">setRaw</span></a></span></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; (FD -&gt; Bool -&gt; IO ()) -&gt; FD -&gt; Bool -&gt; IO ()
forall a. String -&gt; a -&gt; a
</span><a href="GHC.IO.FD.html#ifSupported"><span class="hs-identifier hs-var">ifSupported</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;setRaw&quot;</span></span><span> </span><span class="annot"><span class="annottext">FD -&gt; Bool -&gt; IO ()
</span><a href="GHC.IO.FD.html#setRaw"><span class="hs-identifier hs-var">setRaw</span></a></span><span>
</span><span id="line-132"></span><span>  </span><span id="local-6989586621679555089"><span class="annot"><span class="annottext">devType :: FD -&gt; IO IODeviceType
</span><a href="GHC.IO.Device.html#devType"><span class="hs-identifier hs-var hs-var hs-var hs-var">devType</span></a></span></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; (FD -&gt; IO IODeviceType) -&gt; FD -&gt; IO IODeviceType
forall a. String -&gt; a -&gt; a
</span><a href="GHC.IO.FD.html#ifSupported"><span class="hs-identifier hs-var">ifSupported</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;devType&quot;</span></span><span> </span><span class="annot"><span class="annottext">FD -&gt; IO IODeviceType
</span><a href="GHC.IO.FD.html#devType"><span class="hs-identifier hs-var">devType</span></a></span><span>
</span><span id="line-133"></span><span>  </span><span id="local-6989586621679555086"><span class="annot"><span class="annottext">dup :: FD -&gt; IO FD
</span><a href="GHC.IO.Device.html#dup"><span class="hs-identifier hs-var hs-var hs-var hs-var">dup</span></a></span></span><span>           </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; (FD -&gt; IO FD) -&gt; FD -&gt; IO FD
forall a. String -&gt; a -&gt; a
</span><a href="GHC.IO.FD.html#ifSupported"><span class="hs-identifier hs-var">ifSupported</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;dup&quot;</span></span><span> </span><span class="annot"><span class="annottext">FD -&gt; IO FD
</span><a href="GHC.IO.FD.html#dup"><span class="hs-identifier hs-var">dup</span></a></span><span>
</span><span id="line-134"></span><span>  </span><span id="local-6989586621679555083"><span class="annot"><span class="annottext">dup2 :: FD -&gt; FD -&gt; IO FD
</span><a href="GHC.IO.Device.html#dup2"><span class="hs-identifier hs-var hs-var hs-var hs-var">dup2</span></a></span></span><span>          </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; (FD -&gt; FD -&gt; IO FD) -&gt; FD -&gt; FD -&gt; IO FD
forall a. String -&gt; a -&gt; a
</span><a href="GHC.IO.FD.html#ifSupported"><span class="hs-identifier hs-var">ifSupported</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;dup2&quot;</span></span><span> </span><span class="annot"><span class="annottext">FD -&gt; FD -&gt; IO FD
</span><a href="GHC.IO.FD.html#dup2"><span class="hs-identifier hs-var">dup2</span></a></span><span>
</span><span id="line-135"></span><span>
</span><span id="line-136"></span><span class="hs-comment">-- We used to use System.Posix.Internals.dEFAULT_BUFFER_SIZE, which is</span><span>
</span><span id="line-137"></span><span class="hs-comment">-- taken from the value of BUFSIZ on the current platform.  This value</span><span>
</span><span id="line-138"></span><span class="hs-comment">-- varies too much though: it is 512 on Windows, 1024 on OS X and 8192</span><span>
</span><span id="line-139"></span><span class="hs-comment">-- on Linux.  So let's just use a decent size on every platform:</span><span>
</span><span id="line-140"></span><span class="annot"><a href="GHC.IO.FD.html#dEFAULT_FD_BUFFER_SIZE"><span class="hs-identifier hs-type">dEFAULT_FD_BUFFER_SIZE</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span>
</span><span id="line-141"></span><span id="dEFAULT_FD_BUFFER_SIZE"><span class="annot"><span class="annottext">dEFAULT_FD_BUFFER_SIZE :: Int
</span><a href="GHC.IO.FD.html#dEFAULT_FD_BUFFER_SIZE"><span class="hs-identifier hs-var hs-var">dEFAULT_FD_BUFFER_SIZE</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">8192</span></span><span>
</span><span id="line-142"></span><span>
</span><span id="line-143"></span><span class="hs-comment">-- | @since 4.1.0.0</span><span>
</span><span id="line-144"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621679555075"><span class="annot"><a href="GHC.IO.BufferedIO.html#BufferedIO"><span class="hs-identifier hs-type">BufferedIO</span></a></span><span> </span><span class="annot"><a href="GHC.IO.FD.html#FD"><span class="hs-identifier hs-type">FD</span></a></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-145"></span><span>  </span><span id="local-6989586621679555071"><span class="annot"><span class="annottext">newBuffer :: FD -&gt; BufferState -&gt; IO (Buffer Word8)
</span><a href="GHC.IO.BufferedIO.html#newBuffer"><span class="hs-identifier hs-var hs-var hs-var hs-var">newBuffer</span></a></span></span><span> </span><span id="local-6989586621679555069"><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679555069"><span class="hs-identifier hs-var">_dev</span></a></span></span><span> </span><span id="local-6989586621679555068"><span class="annot"><span class="annottext">BufferState
</span><a href="#local-6989586621679555068"><span class="hs-identifier hs-var">state</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; IO (Buffer Word8) -&gt; IO (Buffer Word8)
forall a. String -&gt; a -&gt; a
</span><a href="GHC.IO.FD.html#ifSupported"><span class="hs-identifier hs-var">ifSupported</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;newBuf&quot;</span></span><span> </span><span class="annot"><span class="annottext">(IO (Buffer Word8) -&gt; IO (Buffer Word8))
-&gt; IO (Buffer Word8) -&gt; IO (Buffer Word8)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; BufferState -&gt; IO (Buffer Word8)
</span><a href="GHC.IO.Buffer.html#newByteBuffer"><span class="hs-identifier hs-var">newByteBuffer</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="GHC.IO.FD.html#dEFAULT_FD_BUFFER_SIZE"><span class="hs-identifier hs-var">dEFAULT_FD_BUFFER_SIZE</span></a></span><span> </span><span class="annot"><span class="annottext">BufferState
</span><a href="#local-6989586621679555068"><span class="hs-identifier hs-var">state</span></a></span><span>
</span><span id="line-146"></span><span>  </span><span id="local-6989586621679555066"><span class="annot"><span class="annottext">fillReadBuffer :: FD -&gt; Buffer Word8 -&gt; IO (Int, Buffer Word8)
</span><a href="GHC.IO.BufferedIO.html#fillReadBuffer"><span class="hs-identifier hs-var hs-var hs-var hs-var">fillReadBuffer</span></a></span></span><span>    </span><span id="local-6989586621679555064"><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679555064"><span class="hs-identifier hs-var">fd</span></a></span></span><span> </span><span id="local-6989586621679555063"><span class="annot"><span class="annottext">Buffer Word8
</span><a href="#local-6989586621679555063"><span class="hs-identifier hs-var">buf</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; IO (Int, Buffer Word8) -&gt; IO (Int, Buffer Word8)
forall a. String -&gt; a -&gt; a
</span><a href="GHC.IO.FD.html#ifSupported"><span class="hs-identifier hs-var">ifSupported</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;readBuf&quot;</span></span><span> </span><span class="annot"><span class="annottext">(IO (Int, Buffer Word8) -&gt; IO (Int, Buffer Word8))
-&gt; IO (Int, Buffer Word8) -&gt; IO (Int, Buffer Word8)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">FD -&gt; Buffer Word8 -&gt; IO (Int, Buffer Word8)
</span><a href="GHC.IO.FD.html#readBuf%27"><span class="hs-identifier hs-var">readBuf'</span></a></span><span> </span><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679555064"><span class="hs-identifier hs-var">fd</span></a></span><span> </span><span class="annot"><span class="annottext">Buffer Word8
</span><a href="#local-6989586621679555063"><span class="hs-identifier hs-var">buf</span></a></span><span>
</span><span id="line-147"></span><span>  </span><span id="local-6989586621679555060"><span class="annot"><span class="annottext">fillReadBuffer0 :: FD -&gt; Buffer Word8 -&gt; IO (Maybe Int, Buffer Word8)
</span><a href="GHC.IO.BufferedIO.html#fillReadBuffer0"><span class="hs-identifier hs-var hs-var hs-var hs-var">fillReadBuffer0</span></a></span></span><span>   </span><span id="local-6989586621679555058"><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679555058"><span class="hs-identifier hs-var">fd</span></a></span></span><span> </span><span id="local-6989586621679555057"><span class="annot"><span class="annottext">Buffer Word8
</span><a href="#local-6989586621679555057"><span class="hs-identifier hs-var">buf</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String
-&gt; IO (Maybe Int, Buffer Word8) -&gt; IO (Maybe Int, Buffer Word8)
forall a. String -&gt; a -&gt; a
</span><a href="GHC.IO.FD.html#ifSupported"><span class="hs-identifier hs-var">ifSupported</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;readBufNonBlock&quot;</span></span><span> </span><span class="annot"><span class="annottext">(IO (Maybe Int, Buffer Word8) -&gt; IO (Maybe Int, Buffer Word8))
-&gt; IO (Maybe Int, Buffer Word8) -&gt; IO (Maybe Int, Buffer Word8)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">FD -&gt; Buffer Word8 -&gt; IO (Maybe Int, Buffer Word8)
forall dev.
RawIO dev =&gt;
dev -&gt; Buffer Word8 -&gt; IO (Maybe Int, Buffer Word8)
</span><a href="GHC.IO.BufferedIO.html#readBufNonBlocking"><span class="hs-identifier hs-var">readBufNonBlocking</span></a></span><span> </span><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679555058"><span class="hs-identifier hs-var">fd</span></a></span><span> </span><span class="annot"><span class="annottext">Buffer Word8
</span><a href="#local-6989586621679555057"><span class="hs-identifier hs-var">buf</span></a></span><span>
</span><span id="line-148"></span><span>  </span><span id="local-6989586621679555055"><span class="annot"><span class="annottext">flushWriteBuffer :: FD -&gt; Buffer Word8 -&gt; IO (Buffer Word8)
</span><a href="GHC.IO.BufferedIO.html#flushWriteBuffer"><span class="hs-identifier hs-var hs-var hs-var hs-var">flushWriteBuffer</span></a></span></span><span>  </span><span id="local-6989586621679555053"><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679555053"><span class="hs-identifier hs-var">fd</span></a></span></span><span> </span><span id="local-6989586621679555052"><span class="annot"><span class="annottext">Buffer Word8
</span><a href="#local-6989586621679555052"><span class="hs-identifier hs-var">buf</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; IO (Buffer Word8) -&gt; IO (Buffer Word8)
forall a. String -&gt; a -&gt; a
</span><a href="GHC.IO.FD.html#ifSupported"><span class="hs-identifier hs-var">ifSupported</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;writeBuf&quot;</span></span><span> </span><span class="annot"><span class="annottext">(IO (Buffer Word8) -&gt; IO (Buffer Word8))
-&gt; IO (Buffer Word8) -&gt; IO (Buffer Word8)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">FD -&gt; Buffer Word8 -&gt; IO (Buffer Word8)
</span><a href="GHC.IO.FD.html#writeBuf%27"><span class="hs-identifier hs-var">writeBuf'</span></a></span><span> </span><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679555053"><span class="hs-identifier hs-var">fd</span></a></span><span> </span><span class="annot"><span class="annottext">Buffer Word8
</span><a href="#local-6989586621679555052"><span class="hs-identifier hs-var">buf</span></a></span><span>
</span><span id="line-149"></span><span>  </span><span id="local-6989586621679555049"><span class="annot"><span class="annottext">flushWriteBuffer0 :: FD -&gt; Buffer Word8 -&gt; IO (Int, Buffer Word8)
</span><a href="GHC.IO.BufferedIO.html#flushWriteBuffer0"><span class="hs-identifier hs-var hs-var hs-var hs-var">flushWriteBuffer0</span></a></span></span><span> </span><span id="local-6989586621679555047"><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679555047"><span class="hs-identifier hs-var">fd</span></a></span></span><span> </span><span id="local-6989586621679555046"><span class="annot"><span class="annottext">Buffer Word8
</span><a href="#local-6989586621679555046"><span class="hs-identifier hs-var">buf</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; IO (Int, Buffer Word8) -&gt; IO (Int, Buffer Word8)
forall a. String -&gt; a -&gt; a
</span><a href="GHC.IO.FD.html#ifSupported"><span class="hs-identifier hs-var">ifSupported</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;writeBufNonBlock&quot;</span></span><span> </span><span class="annot"><span class="annottext">(IO (Int, Buffer Word8) -&gt; IO (Int, Buffer Word8))
-&gt; IO (Int, Buffer Word8) -&gt; IO (Int, Buffer Word8)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">FD -&gt; Buffer Word8 -&gt; IO (Int, Buffer Word8)
forall dev.
RawIO dev =&gt;
dev -&gt; Buffer Word8 -&gt; IO (Int, Buffer Word8)
</span><a href="GHC.IO.BufferedIO.html#writeBufNonBlocking"><span class="hs-identifier hs-var">writeBufNonBlocking</span></a></span><span> </span><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679555047"><span class="hs-identifier hs-var">fd</span></a></span><span> </span><span class="annot"><span class="annottext">Buffer Word8
</span><a href="#local-6989586621679555046"><span class="hs-identifier hs-var">buf</span></a></span><span>
</span><span id="line-150"></span><span>
</span><span id="line-151"></span><span class="annot"><a href="GHC.IO.FD.html#readBuf%27"><span class="hs-identifier hs-type">readBuf'</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.FD.html#FD"><span class="hs-identifier hs-type">FD</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.IO.Buffer.html#Buffer"><span class="hs-identifier hs-type">Buffer</span></a></span><span> </span><span class="annot"><a href="GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Buffer.html#Buffer"><span class="hs-identifier hs-type">Buffer</span></a></span><span> </span><span class="annot"><a href="GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-152"></span><span id="readBuf%27"><span class="annot"><span class="annottext">readBuf' :: FD -&gt; Buffer Word8 -&gt; IO (Int, Buffer Word8)
</span><a href="GHC.IO.FD.html#readBuf%27"><span class="hs-identifier hs-var hs-var">readBuf'</span></a></span></span><span> </span><span id="local-6989586621679555044"><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679555044"><span class="hs-identifier hs-var">fd</span></a></span></span><span> </span><span id="local-6989586621679555043"><span class="annot"><span class="annottext">Buffer Word8
</span><a href="#local-6989586621679555043"><span class="hs-identifier hs-var">buf</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-153"></span><span>  </span><span class="annot"><span class="annottext">Bool -&gt; IO () -&gt; IO ()
forall (f :: * -&gt; *). Applicative f =&gt; Bool -&gt; f () -&gt; f ()
</span><a href="GHC.Base.html#when"><span class="hs-identifier hs-var">when</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="GHC.IO.FD.html#c_DEBUG_DUMP"><span class="hs-identifier hs-var">c_DEBUG_DUMP</span></a></span><span> </span><span class="annot"><span class="annottext">(IO () -&gt; IO ()) -&gt; IO () -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-154"></span><span>      </span><span class="annot"><span class="annottext">String -&gt; IO ()
</span><a href="System.Posix.Internals.html#puts"><span class="hs-identifier hs-var">puts</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;readBuf fd=&quot;</span></span><span> </span><span class="annot"><span class="annottext">String -&gt; ShowS
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">FD -&gt; String
forall a. Show a =&gt; a -&gt; String
</span><a href="GHC.Show.html#show"><span class="hs-identifier hs-var">show</span></a></span><span> </span><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679555044"><span class="hs-identifier hs-var">fd</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; ShowS
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot; &quot;</span></span><span> </span><span class="annot"><span class="annottext">String -&gt; ShowS
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">Buffer Word8 -&gt; String
forall a. Buffer a -&gt; String
</span><a href="GHC.IO.Buffer.html#summaryBuffer"><span class="hs-identifier hs-var">summaryBuffer</span></a></span><span> </span><span class="annot"><span class="annottext">Buffer Word8
</span><a href="#local-6989586621679555043"><span class="hs-identifier hs-var">buf</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; ShowS
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;\n&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-155"></span><span>  </span><span class="hs-special">(</span><span id="local-6989586621679555039"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679555039"><span class="hs-identifier hs-var">r</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621679555038"><span class="annot"><span class="annottext">Buffer Word8
</span><a href="#local-6989586621679555038"><span class="hs-identifier hs-var">buf'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FD -&gt; Buffer Word8 -&gt; IO (Int, Buffer Word8)
forall dev.
RawIO dev =&gt;
dev -&gt; Buffer Word8 -&gt; IO (Int, Buffer Word8)
</span><a href="GHC.IO.BufferedIO.html#readBuf"><span class="hs-identifier hs-var">readBuf</span></a></span><span> </span><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679555044"><span class="hs-identifier hs-var">fd</span></a></span><span> </span><span class="annot"><span class="annottext">Buffer Word8
</span><a href="#local-6989586621679555043"><span class="hs-identifier hs-var">buf</span></a></span><span>
</span><span id="line-156"></span><span>  </span><span class="annot"><span class="annottext">Bool -&gt; IO () -&gt; IO ()
forall (f :: * -&gt; *). Applicative f =&gt; Bool -&gt; f () -&gt; f ()
</span><a href="GHC.Base.html#when"><span class="hs-identifier hs-var">when</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="GHC.IO.FD.html#c_DEBUG_DUMP"><span class="hs-identifier hs-var">c_DEBUG_DUMP</span></a></span><span> </span><span class="annot"><span class="annottext">(IO () -&gt; IO ()) -&gt; IO () -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-157"></span><span>      </span><span class="annot"><span class="annottext">String -&gt; IO ()
</span><a href="System.Posix.Internals.html#puts"><span class="hs-identifier hs-var">puts</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;after: &quot;</span></span><span> </span><span class="annot"><span class="annottext">String -&gt; ShowS
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">Buffer Word8 -&gt; String
forall a. Buffer a -&gt; String
</span><a href="GHC.IO.Buffer.html#summaryBuffer"><span class="hs-identifier hs-var">summaryBuffer</span></a></span><span> </span><span class="annot"><span class="annottext">Buffer Word8
</span><a href="#local-6989586621679555038"><span class="hs-identifier hs-var">buf'</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; ShowS
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;\n&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-158"></span><span>  </span><span class="annot"><span class="annottext">(Int, Buffer Word8) -&gt; IO (Int, Buffer Word8)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679555039"><span class="hs-identifier hs-var">r</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Buffer Word8
</span><a href="#local-6989586621679555038"><span class="hs-identifier hs-var">buf'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-159"></span><span>
</span><span id="line-160"></span><span class="annot"><a href="GHC.IO.FD.html#writeBuf%27"><span class="hs-identifier hs-type">writeBuf'</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.FD.html#FD"><span class="hs-identifier hs-type">FD</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.IO.Buffer.html#Buffer"><span class="hs-identifier hs-type">Buffer</span></a></span><span> </span><span class="annot"><a href="GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.IO.Buffer.html#Buffer"><span class="hs-identifier hs-type">Buffer</span></a></span><span> </span><span class="annot"><a href="GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-161"></span><span id="writeBuf%27"><span class="annot"><span class="annottext">writeBuf' :: FD -&gt; Buffer Word8 -&gt; IO (Buffer Word8)
</span><a href="GHC.IO.FD.html#writeBuf%27"><span class="hs-identifier hs-var hs-var">writeBuf'</span></a></span></span><span> </span><span id="local-6989586621679555036"><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679555036"><span class="hs-identifier hs-var">fd</span></a></span></span><span> </span><span id="local-6989586621679555035"><span class="annot"><span class="annottext">Buffer Word8
</span><a href="#local-6989586621679555035"><span class="hs-identifier hs-var">buf</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-162"></span><span>  </span><span class="annot"><span class="annottext">Bool -&gt; IO () -&gt; IO ()
forall (f :: * -&gt; *). Applicative f =&gt; Bool -&gt; f () -&gt; f ()
</span><a href="GHC.Base.html#when"><span class="hs-identifier hs-var">when</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="GHC.IO.FD.html#c_DEBUG_DUMP"><span class="hs-identifier hs-var">c_DEBUG_DUMP</span></a></span><span> </span><span class="annot"><span class="annottext">(IO () -&gt; IO ()) -&gt; IO () -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-163"></span><span>      </span><span class="annot"><span class="annottext">String -&gt; IO ()
</span><a href="System.Posix.Internals.html#puts"><span class="hs-identifier hs-var">puts</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;writeBuf fd=&quot;</span></span><span> </span><span class="annot"><span class="annottext">String -&gt; ShowS
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">FD -&gt; String
forall a. Show a =&gt; a -&gt; String
</span><a href="GHC.Show.html#show"><span class="hs-identifier hs-var">show</span></a></span><span> </span><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679555036"><span class="hs-identifier hs-var">fd</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; ShowS
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot; &quot;</span></span><span> </span><span class="annot"><span class="annottext">String -&gt; ShowS
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">Buffer Word8 -&gt; String
forall a. Buffer a -&gt; String
</span><a href="GHC.IO.Buffer.html#summaryBuffer"><span class="hs-identifier hs-var">summaryBuffer</span></a></span><span> </span><span class="annot"><span class="annottext">Buffer Word8
</span><a href="#local-6989586621679555035"><span class="hs-identifier hs-var">buf</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; ShowS
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;\n&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-164"></span><span>  </span><span class="annot"><span class="annottext">FD -&gt; Buffer Word8 -&gt; IO (Buffer Word8)
forall dev. RawIO dev =&gt; dev -&gt; Buffer Word8 -&gt; IO (Buffer Word8)
</span><a href="GHC.IO.BufferedIO.html#writeBuf"><span class="hs-identifier hs-var">writeBuf</span></a></span><span> </span><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679555036"><span class="hs-identifier hs-var">fd</span></a></span><span> </span><span class="annot"><span class="annottext">Buffer Word8
</span><a href="#local-6989586621679555035"><span class="hs-identifier hs-var">buf</span></a></span><span>
</span><span id="line-165"></span><span>
</span><span id="line-166"></span><span class="hs-comment">-- -----------------------------------------------------------------------------</span><span>
</span><span id="line-167"></span><span class="hs-comment">-- opening files</span><span>
</span><span id="line-168"></span><span>
</span><span id="line-169"></span><span class="hs-comment">-- | Open a file and make an 'FD' for it.  Truncates the file to zero</span><span>
</span><span id="line-170"></span><span class="hs-comment">-- size when the `IOMode` is `WriteMode`.</span><span>
</span><span id="line-171"></span><span class="annot"><a href="GHC.IO.FD.html#openFile"><span class="hs-identifier hs-type">openFile</span></a></span><span>
</span><span id="line-172"></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-comment">-- ^ file to open</span><span>
</span><span id="line-173"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.IO.IOMode.html#IOMode"><span class="hs-identifier hs-type">IOMode</span></a></span><span>   </span><span class="hs-comment">-- ^ mode in which to open the file</span><span>
</span><span id="line-174"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Bool"><span class="hs-identifier hs-type">Bool</span></a></span><span>     </span><span class="hs-comment">-- ^ open the file in non-blocking mode?</span><span>
</span><span id="line-175"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.IO.FD.html#FD"><span class="hs-identifier hs-type">FD</span></a></span><span class="hs-special">,</span><span class="annot"><a href="GHC.IO.Device.html#IODeviceType"><span class="hs-identifier hs-type">IODeviceType</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-176"></span><span>
</span><span id="line-177"></span><span id="openFile"><span class="annot"><span class="annottext">openFile :: String -&gt; IOMode -&gt; Bool -&gt; IO (FD, IODeviceType)
</span><a href="GHC.IO.FD.html#openFile"><span class="hs-identifier hs-var hs-var">openFile</span></a></span></span><span> </span><span id="local-6989586621679555032"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679555032"><span class="hs-identifier hs-var">filepath</span></a></span></span><span> </span><span id="local-6989586621679555031"><span class="annot"><span class="annottext">IOMode
</span><a href="#local-6989586621679555031"><span class="hs-identifier hs-var">iomode</span></a></span></span><span> </span><span id="local-6989586621679555030"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679555030"><span class="hs-identifier hs-var">non_blocking</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-178"></span><span>  </span><span class="annot"><span class="annottext">String
-&gt; (CWString -&gt; IO (FD, IODeviceType)) -&gt; IO (FD, IODeviceType)
forall a. String -&gt; (CWString -&gt; IO a) -&gt; IO a
</span><a href="System.Posix.Internals.html#withFilePath"><span class="hs-identifier hs-var">withFilePath</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679555032"><span class="hs-identifier hs-var">filepath</span></a></span><span> </span><span class="annot"><span class="annottext">((CWString -&gt; IO (FD, IODeviceType)) -&gt; IO (FD, IODeviceType))
-&gt; (CWString -&gt; IO (FD, IODeviceType)) -&gt; IO (FD, IODeviceType)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span id="local-6989586621679555028"><span class="annot"><span class="annottext">CWString
</span><a href="#local-6989586621679555028"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-179"></span><span>
</span><span id="line-180"></span><span>    </span><span class="hs-keyword">let</span><span>
</span><span id="line-181"></span><span>      </span><span id="local-6989586621679555027"><span class="annot"><span class="annottext">oflags1 :: CInt
</span><a href="#local-6989586621679555027"><span class="hs-identifier hs-var hs-var">oflags1</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">IOMode
</span><a href="#local-6989586621679555031"><span class="hs-identifier hs-var">iomode</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-182"></span><span>                  </span><span class="annot"><span class="annottext">IOMode
</span><a href="GHC.IO.IOMode.html#ReadMode"><span class="hs-identifier hs-var">ReadMode</span></a></span><span>      </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CInt
</span><a href="GHC.IO.FD.html#read_flags"><span class="hs-identifier hs-var">read_flags</span></a></span><span>
</span><span id="line-183"></span><span>                  </span><span class="annot"><span class="annottext">IOMode
</span><a href="GHC.IO.IOMode.html#WriteMode"><span class="hs-identifier hs-var">WriteMode</span></a></span><span>     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CInt
</span><a href="GHC.IO.FD.html#write_flags"><span class="hs-identifier hs-var">write_flags</span></a></span><span>
</span><span id="line-184"></span><span>                  </span><span class="annot"><span class="annottext">IOMode
</span><a href="GHC.IO.IOMode.html#ReadWriteMode"><span class="hs-identifier hs-var">ReadWriteMode</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CInt
</span><a href="GHC.IO.FD.html#rw_flags"><span class="hs-identifier hs-var">rw_flags</span></a></span><span>
</span><span id="line-185"></span><span>                  </span><span class="annot"><span class="annottext">IOMode
</span><a href="GHC.IO.IOMode.html#AppendMode"><span class="hs-identifier hs-var">AppendMode</span></a></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CInt
</span><a href="GHC.IO.FD.html#append_flags"><span class="hs-identifier hs-var">append_flags</span></a></span><span class="hs-cpp">

#if defined(mingw32_HOST_OS)
</span><span>      </span><span id="local-6989586621679555018"><span class="annot"><span class="annottext">binary_flags :: CInt
</span><a href="#local-6989586621679555018"><span class="hs-identifier hs-var hs-var">binary_flags</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CInt
</span><a href="System.Posix.Internals.html#o_BINARY"><span class="hs-identifier hs-var">o_BINARY</span></a></span><span class="hs-cpp">
#else
</span><span>      </span><span class="hs-identifier">binary_flags</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-number">0</span><span class="hs-cpp">
#endif
</span><span>
</span><span id="line-193"></span><span>      </span><span id="local-6989586621679555015"><span class="annot"><span class="annottext">oflags2 :: CInt
</span><a href="#local-6989586621679555015"><span class="hs-identifier hs-var hs-var">oflags2</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679555027"><span class="hs-identifier hs-var">oflags1</span></a></span><span> </span><span class="annot"><span class="annottext">CInt -&gt; CInt -&gt; CInt
forall a. Bits a =&gt; a -&gt; a -&gt; a
</span><a href="Data.Bits.html#.%7C."><span class="hs-operator hs-var">.|.</span></a></span><span> </span><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679555018"><span class="hs-identifier hs-var">binary_flags</span></a></span><span>
</span><span id="line-194"></span><span>
</span><span id="line-195"></span><span>      </span><span id="local-6989586621679555012"><span class="annot"><span class="annottext">oflags :: CInt
</span><a href="#local-6989586621679555012"><span class="hs-identifier hs-var hs-var">oflags</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679555030"><span class="hs-identifier hs-var">non_blocking</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679555015"><span class="hs-identifier hs-var">oflags2</span></a></span><span> </span><span class="annot"><span class="annottext">CInt -&gt; CInt -&gt; CInt
forall a. Bits a =&gt; a -&gt; a -&gt; a
</span><a href="Data.Bits.html#.%7C."><span class="hs-operator hs-var">.|.</span></a></span><span> </span><span class="annot"><span class="annottext">CInt
</span><a href="GHC.IO.FD.html#nonblock_flags"><span class="hs-identifier hs-var">nonblock_flags</span></a></span><span>
</span><span id="line-196"></span><span>             </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679555015"><span class="hs-identifier hs-var">oflags2</span></a></span><span>
</span><span id="line-197"></span><span>    </span><span class="hs-keyword">in</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-198"></span><span>
</span><span id="line-199"></span><span>    </span><span class="hs-comment">-- NB. always use a safe open(), because we don't know whether open()</span><span>
</span><span id="line-200"></span><span>    </span><span class="hs-comment">-- will be fast or not.  It can be slow on NFS and FUSE filesystems,</span><span>
</span><span id="line-201"></span><span>    </span><span class="hs-comment">-- for example.</span><span>
</span><span id="line-202"></span><span>    </span><span id="local-6989586621679555010"><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679555010"><span class="hs-identifier hs-var">fd</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">String -&gt; IO CInt -&gt; IO CInt
forall a. (Eq a, Num a) =&gt; String -&gt; IO a -&gt; IO a
</span><a href="Foreign.C.Error.html#throwErrnoIfMinus1Retry"><span class="hs-identifier hs-var">throwErrnoIfMinus1Retry</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;openFile&quot;</span></span><span> </span><span class="annot"><span class="annottext">(IO CInt -&gt; IO CInt) -&gt; IO CInt -&gt; IO CInt
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">CWString -&gt; CInt -&gt; CMode -&gt; IO CInt
</span><a href="System.Posix.Internals.html#c_safe_open"><span class="hs-identifier hs-var">c_safe_open</span></a></span><span> </span><span class="annot"><span class="annottext">CWString
</span><a href="#local-6989586621679555028"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679555012"><span class="hs-identifier hs-var">oflags</span></a></span><span> </span><span class="annot"><span class="annottext">CMode
</span><span class="hs-number">0o666</span></span><span>
</span><span id="line-203"></span><span>
</span><span id="line-204"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621679555007"><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679555007"><span class="hs-identifier hs-var">fD</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621679555006"><span class="annot"><span class="annottext">IODeviceType
</span><a href="#local-6989586621679555006"><span class="hs-identifier hs-var">fd_type</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CInt
-&gt; IOMode
-&gt; Maybe (IODeviceType, CDev, CIno)
-&gt; Bool
-&gt; Bool
-&gt; IO (FD, IODeviceType)
</span><a href="GHC.IO.FD.html#mkFD"><span class="hs-identifier hs-var">mkFD</span></a></span><span> </span><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679555010"><span class="hs-identifier hs-var">fd</span></a></span><span> </span><span class="annot"><span class="annottext">IOMode
</span><a href="#local-6989586621679555031"><span class="hs-identifier hs-var">iomode</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe (IODeviceType, CDev, CIno)
forall a. Maybe a
</span><a href="GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span class="hs-comment">{-no stat-}</span><span>
</span><span id="line-205"></span><span>                            </span><span class="annot"><span class="annottext">Bool
</span><a href="../../ghc-prim/src/GHC.Types.html#False"><span class="hs-identifier hs-var">False</span></a></span><span class="hs-comment">{-not a socket-}</span><span>
</span><span id="line-206"></span><span>                            </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679555030"><span class="hs-identifier hs-var">non_blocking</span></a></span><span>
</span><span id="line-207"></span><span>            </span><span class="annot"><span class="annottext">IO (FD, IODeviceType)
-&gt; (forall e. Exception e =&gt; e -&gt; IO (FD, IODeviceType))
-&gt; IO (FD, IODeviceType)
forall a. IO a -&gt; (forall e. Exception e =&gt; e -&gt; IO a) -&gt; IO a
</span><a href="GHC.IO.html#catchAny"><span class="hs-operator hs-var">`catchAny`</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679555001"><span class="annot"><span class="annottext">e
</span><a href="#local-6989586621679555001"><span class="hs-identifier hs-var">e</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="annot"><span class="annottext">CInt
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CInt -&gt; IO CInt
</span><a href="System.Posix.Internals.html#c_close"><span class="hs-identifier hs-var">c_close</span></a></span><span> </span><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679555010"><span class="hs-identifier hs-var">fd</span></a></span><span>
</span><span id="line-208"></span><span>                                </span><span class="annot"><span class="annottext">e -&gt; IO (FD, IODeviceType)
forall e a. Exception e =&gt; e -&gt; IO a
</span><a href="GHC.IO.html#throwIO"><span class="hs-identifier hs-var">throwIO</span></a></span><span> </span><span class="annot"><span class="annottext">e
</span><a href="#local-6989586621679555001"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-209"></span><span>
</span><span id="line-210"></span><span>    </span><span class="hs-comment">-- we want to truncate() if this is an open in WriteMode, but only</span><span>
</span><span id="line-211"></span><span>    </span><span class="hs-comment">-- if the target is a RegularFile.  ftruncate() fails on special files</span><span>
</span><span id="line-212"></span><span>    </span><span class="hs-comment">-- like /dev/null.</span><span>
</span><span id="line-213"></span><span>    </span><span class="annot"><span class="annottext">Bool -&gt; IO () -&gt; IO ()
forall (f :: * -&gt; *). Applicative f =&gt; Bool -&gt; f () -&gt; f ()
</span><a href="GHC.Base.html#when"><span class="hs-identifier hs-var">when</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IOMode
</span><a href="#local-6989586621679555031"><span class="hs-identifier hs-var">iomode</span></a></span><span> </span><span class="annot"><span class="annottext">IOMode -&gt; IOMode -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3D%3D"><span class="hs-operator hs-var">==</span></a></span><span> </span><span class="annot"><span class="annottext">IOMode
</span><a href="GHC.IO.IOMode.html#WriteMode"><span class="hs-identifier hs-var">WriteMode</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%26%26"><span class="hs-operator hs-var">&amp;&amp;</span></a></span><span> </span><span class="annot"><span class="annottext">IODeviceType
</span><a href="#local-6989586621679555006"><span class="hs-identifier hs-var">fd_type</span></a></span><span> </span><span class="annot"><span class="annottext">IODeviceType -&gt; IODeviceType -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3D%3D"><span class="hs-operator hs-var">==</span></a></span><span> </span><span class="annot"><span class="annottext">IODeviceType
</span><a href="GHC.IO.Device.html#RegularFile"><span class="hs-identifier hs-var">RegularFile</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(IO () -&gt; IO ()) -&gt; IO () -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-214"></span><span>      </span><span class="annot"><span class="annottext">FD -&gt; Integer -&gt; IO ()
</span><a href="GHC.IO.FD.html#setSize"><span class="hs-identifier hs-var">setSize</span></a></span><span> </span><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679555007"><span class="hs-identifier hs-var">fD</span></a></span><span> </span><span class="annot"><span class="annottext">Integer
</span><span class="hs-number">0</span></span><span>
</span><span id="line-215"></span><span>
</span><span id="line-216"></span><span>    </span><span class="annot"><span class="annottext">(FD, IODeviceType) -&gt; IO (FD, IODeviceType)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679555007"><span class="hs-identifier hs-var">fD</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">IODeviceType
</span><a href="#local-6989586621679555006"><span class="hs-identifier hs-var">fd_type</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-217"></span><span>
</span><span id="line-218"></span><span class="annot"><a href="GHC.IO.FD.html#std_flags"><span class="hs-identifier hs-type">std_flags</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.FD.html#output_flags"><span class="hs-identifier hs-type">output_flags</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.FD.html#read_flags"><span class="hs-identifier hs-type">read_flags</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.FD.html#write_flags"><span class="hs-identifier hs-type">write_flags</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.FD.html#rw_flags"><span class="hs-identifier hs-type">rw_flags</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-219"></span><span>    </span><span class="annot"><a href="GHC.IO.FD.html#append_flags"><span class="hs-identifier hs-type">append_flags</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.FD.html#nonblock_flags"><span class="hs-identifier hs-type">nonblock_flags</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Foreign.C.Types.html#CInt"><span class="hs-identifier hs-type">CInt</span></a></span><span>
</span><span id="line-220"></span><span id="std_flags"><span class="annot"><span class="annottext">std_flags :: CInt
</span><a href="GHC.IO.FD.html#std_flags"><span class="hs-identifier hs-var hs-var">std_flags</span></a></span></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CInt
</span><a href="System.Posix.Internals.html#o_NOCTTY"><span class="hs-identifier hs-var">o_NOCTTY</span></a></span><span>
</span><span id="line-221"></span><span id="output_flags"><span class="annot"><span class="annottext">output_flags :: CInt
</span><a href="GHC.IO.FD.html#output_flags"><span class="hs-identifier hs-var hs-var">output_flags</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CInt
</span><a href="GHC.IO.FD.html#std_flags"><span class="hs-identifier hs-var">std_flags</span></a></span><span>    </span><span class="annot"><span class="annottext">CInt -&gt; CInt -&gt; CInt
forall a. Bits a =&gt; a -&gt; a -&gt; a
</span><a href="Data.Bits.html#.%7C."><span class="hs-operator hs-var">.|.</span></a></span><span> </span><span class="annot"><span class="annottext">CInt
</span><a href="System.Posix.Internals.html#o_CREAT"><span class="hs-identifier hs-var">o_CREAT</span></a></span><span>
</span><span id="line-222"></span><span id="read_flags"><span class="annot"><span class="annottext">read_flags :: CInt
</span><a href="GHC.IO.FD.html#read_flags"><span class="hs-identifier hs-var hs-var">read_flags</span></a></span></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CInt
</span><a href="GHC.IO.FD.html#std_flags"><span class="hs-identifier hs-var">std_flags</span></a></span><span>    </span><span class="annot"><span class="annottext">CInt -&gt; CInt -&gt; CInt
forall a. Bits a =&gt; a -&gt; a -&gt; a
</span><a href="Data.Bits.html#.%7C."><span class="hs-operator hs-var">.|.</span></a></span><span> </span><span class="annot"><span class="annottext">CInt
</span><a href="System.Posix.Internals.html#o_RDONLY"><span class="hs-identifier hs-var">o_RDONLY</span></a></span><span>
</span><span id="line-223"></span><span id="write_flags"><span class="annot"><span class="annottext">write_flags :: CInt
</span><a href="GHC.IO.FD.html#write_flags"><span class="hs-identifier hs-var hs-var">write_flags</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CInt
</span><a href="GHC.IO.FD.html#output_flags"><span class="hs-identifier hs-var">output_flags</span></a></span><span> </span><span class="annot"><span class="annottext">CInt -&gt; CInt -&gt; CInt
forall a. Bits a =&gt; a -&gt; a -&gt; a
</span><a href="Data.Bits.html#.%7C."><span class="hs-operator hs-var">.|.</span></a></span><span> </span><span class="annot"><span class="annottext">CInt
</span><a href="System.Posix.Internals.html#o_WRONLY"><span class="hs-identifier hs-var">o_WRONLY</span></a></span><span>
</span><span id="line-224"></span><span id="rw_flags"><span class="annot"><span class="annottext">rw_flags :: CInt
</span><a href="GHC.IO.FD.html#rw_flags"><span class="hs-identifier hs-var hs-var">rw_flags</span></a></span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CInt
</span><a href="GHC.IO.FD.html#output_flags"><span class="hs-identifier hs-var">output_flags</span></a></span><span> </span><span class="annot"><span class="annottext">CInt -&gt; CInt -&gt; CInt
forall a. Bits a =&gt; a -&gt; a -&gt; a
</span><a href="Data.Bits.html#.%7C."><span class="hs-operator hs-var">.|.</span></a></span><span> </span><span class="annot"><span class="annottext">CInt
</span><a href="System.Posix.Internals.html#o_RDWR"><span class="hs-identifier hs-var">o_RDWR</span></a></span><span>
</span><span id="line-225"></span><span id="append_flags"><span class="annot"><span class="annottext">append_flags :: CInt
</span><a href="GHC.IO.FD.html#append_flags"><span class="hs-identifier hs-var hs-var">append_flags</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CInt
</span><a href="GHC.IO.FD.html#write_flags"><span class="hs-identifier hs-var">write_flags</span></a></span><span>  </span><span class="annot"><span class="annottext">CInt -&gt; CInt -&gt; CInt
forall a. Bits a =&gt; a -&gt; a -&gt; a
</span><a href="Data.Bits.html#.%7C."><span class="hs-operator hs-var">.|.</span></a></span><span> </span><span class="annot"><span class="annottext">CInt
</span><a href="System.Posix.Internals.html#o_APPEND"><span class="hs-identifier hs-var">o_APPEND</span></a></span><span>
</span><span id="line-226"></span><span id="nonblock_flags"><span class="annot"><span class="annottext">nonblock_flags :: CInt
</span><a href="GHC.IO.FD.html#nonblock_flags"><span class="hs-identifier hs-var hs-var">nonblock_flags</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CInt
</span><a href="System.Posix.Internals.html#o_NONBLOCK"><span class="hs-identifier hs-var">o_NONBLOCK</span></a></span><span>
</span><span id="line-227"></span><span>
</span><span id="line-228"></span><span>
</span><span id="line-229"></span><span class="hs-comment">-- | Make a 'FD' from an existing file descriptor.  Fails if the FD</span><span>
</span><span id="line-230"></span><span class="hs-comment">-- refers to a directory.  If the FD refers to a file, `mkFD` locks</span><span>
</span><span id="line-231"></span><span class="hs-comment">-- the file according to the Haskell 2010 single writer/multiple reader</span><span>
</span><span id="line-232"></span><span class="hs-comment">-- locking semantics (this is why we need the `IOMode` argument too).</span><span>
</span><span id="line-233"></span><span class="annot"><a href="GHC.IO.FD.html#mkFD"><span class="hs-identifier hs-type">mkFD</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Foreign.C.Types.html#CInt"><span class="hs-identifier hs-type">CInt</span></a></span><span>
</span><span id="line-234"></span><span>     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.IO.IOMode.html#IOMode"><span class="hs-identifier hs-type">IOMode</span></a></span><span>
</span><span id="line-235"></span><span>     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.IO.Device.html#IODeviceType"><span class="hs-identifier hs-type">IODeviceType</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="System.Posix.Types.html#CDev"><span class="hs-identifier hs-type">CDev</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="System.Posix.Types.html#CIno"><span class="hs-identifier hs-type">CIno</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-236"></span><span>     </span><span class="hs-comment">-- the results of fdStat if we already know them, or we want</span><span>
</span><span id="line-237"></span><span>     </span><span class="hs-comment">-- to prevent fdToHandle_stat from doing its own stat.</span><span>
</span><span id="line-238"></span><span>     </span><span class="hs-comment">-- These are used for:</span><span>
</span><span id="line-239"></span><span>     </span><span class="hs-comment">--   - we fail if the FD refers to a directory</span><span>
</span><span id="line-240"></span><span>     </span><span class="hs-comment">--   - if the FD refers to a file, we lock it using (cdev,cino)</span><span>
</span><span id="line-241"></span><span>     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Bool"><span class="hs-identifier hs-type">Bool</span></a></span><span>   </span><span class="hs-comment">-- ^ is a socket (on Windows)</span><span>
</span><span id="line-242"></span><span>     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Bool"><span class="hs-identifier hs-type">Bool</span></a></span><span>   </span><span class="hs-comment">-- ^ is in non-blocking mode on Unix</span><span>
</span><span id="line-243"></span><span>     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.IO.FD.html#FD"><span class="hs-identifier hs-type">FD</span></a></span><span class="hs-special">,</span><span class="annot"><a href="GHC.IO.Device.html#IODeviceType"><span class="hs-identifier hs-type">IODeviceType</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-244"></span><span>
</span><span id="line-245"></span><span id="mkFD"><span class="annot"><span class="annottext">mkFD :: CInt
-&gt; IOMode
-&gt; Maybe (IODeviceType, CDev, CIno)
-&gt; Bool
-&gt; Bool
-&gt; IO (FD, IODeviceType)
</span><a href="GHC.IO.FD.html#mkFD"><span class="hs-identifier hs-var hs-var">mkFD</span></a></span></span><span> </span><span id="local-6989586621679554987"><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679554987"><span class="hs-identifier hs-var">fd</span></a></span></span><span> </span><span id="local-6989586621679554986"><span class="annot"><span class="annottext">IOMode
</span><a href="#local-6989586621679554986"><span class="hs-identifier hs-var">iomode</span></a></span></span><span> </span><span id="local-6989586621679554985"><span class="annot"><span class="annottext">Maybe (IODeviceType, CDev, CIno)
</span><a href="#local-6989586621679554985"><span class="hs-identifier hs-var">mb_stat</span></a></span></span><span> </span><span id="local-6989586621679554984"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679554984"><span class="hs-identifier hs-var">is_socket</span></a></span></span><span> </span><span id="local-6989586621679554983"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679554983"><span class="hs-identifier hs-var">is_nonblock</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-246"></span><span>
</span><span id="line-247"></span><span>    </span><span class="hs-keyword">let</span><span> </span><span class="annot"><span class="annottext">(Bool, Bool)
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679554984"><span class="hs-identifier hs-var">is_socket</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679554983"><span class="hs-identifier hs-var">is_nonblock</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-comment">-- warning suppression</span><span>
</span><span id="line-248"></span><span>
</span><span id="line-249"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621679554982"><span class="annot"><span class="annottext">IODeviceType
</span><a href="#local-6989586621679554982"><span class="hs-identifier hs-var">fd_type</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621679554981"><span class="annot"><span class="annottext">CDev
</span><a href="#local-6989586621679554981"><span class="hs-identifier hs-var">dev</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621679554980"><span class="annot"><span class="annottext">CIno
</span><a href="#local-6989586621679554980"><span class="hs-identifier hs-var">ino</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span>
</span><span id="line-250"></span><span>        </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Maybe (IODeviceType, CDev, CIno)
</span><a href="#local-6989586621679554985"><span class="hs-identifier hs-var">mb_stat</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-251"></span><span>          </span><span class="annot"><span class="annottext">Maybe (IODeviceType, CDev, CIno)
</span><a href="GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CInt -&gt; IO (IODeviceType, CDev, CIno)
</span><a href="System.Posix.Internals.html#fdStat"><span class="hs-identifier hs-var">fdStat</span></a></span><span> </span><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679554987"><span class="hs-identifier hs-var">fd</span></a></span><span>
</span><span id="line-252"></span><span>          </span><span class="annot"><a href="GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621679554978"><span class="annot"><span class="annottext">(IODeviceType, CDev, CIno)
</span><a href="#local-6989586621679554978"><span class="hs-identifier hs-var">stat</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">(IODeviceType, CDev, CIno) -&gt; IO (IODeviceType, CDev, CIno)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(IODeviceType, CDev, CIno)
</span><a href="#local-6989586621679554978"><span class="hs-identifier hs-var">stat</span></a></span><span>
</span><span id="line-253"></span><span>
</span><span id="line-254"></span><span>    </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679554977"><span class="annot"><span class="annottext">write :: Bool
</span><a href="#local-6989586621679554977"><span class="hs-identifier hs-var hs-var">write</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">IOMode
</span><a href="#local-6989586621679554986"><span class="hs-identifier hs-var">iomode</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-255"></span><span>                   </span><span class="annot"><span class="annottext">IOMode
</span><a href="GHC.IO.IOMode.html#ReadMode"><span class="hs-identifier hs-var">ReadMode</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../ghc-prim/src/GHC.Types.html#False"><span class="hs-identifier hs-var">False</span></a></span><span>
</span><span id="line-256"></span><span>                   </span><span class="annot"><span class="annottext">IOMode
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../ghc-prim/src/GHC.Types.html#True"><span class="hs-identifier hs-var">True</span></a></span><span>
</span><span id="line-257"></span><span>
</span><span id="line-258"></span><span>    </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">IODeviceType
</span><a href="#local-6989586621679554982"><span class="hs-identifier hs-var">fd_type</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-259"></span><span>        </span><span class="annot"><span class="annottext">IODeviceType
</span><a href="GHC.IO.Device.html#Directory"><span class="hs-identifier hs-var">Directory</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-260"></span><span>           </span><span class="annot"><span class="annottext">IOException -&gt; IO ()
forall a. IOException -&gt; IO a
</span><a href="GHC.IO.Exception.html#ioException"><span class="hs-identifier hs-var">ioException</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Maybe Handle
-&gt; IOErrorType
-&gt; String
-&gt; String
-&gt; Maybe CInt
-&gt; Maybe String
-&gt; IOException
</span><a href="GHC.IO.Exception.html#IOError"><span class="hs-identifier hs-var">IOError</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Handle
forall a. Maybe a
</span><a href="GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="annot"><span class="annottext">IOErrorType
</span><a href="GHC.IO.Exception.html#InappropriateType"><span class="hs-identifier hs-var">InappropriateType</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;openFile&quot;</span></span><span>
</span><span id="line-261"></span><span>                           </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;is a directory&quot;</span></span><span> </span><span class="annot"><span class="annottext">Maybe CInt
forall a. Maybe a
</span><a href="GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe String
forall a. Maybe a
</span><a href="GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-262"></span><span>
</span><span id="line-263"></span><span>        </span><span class="hs-comment">-- regular files need to be locked</span><span>
</span><span id="line-264"></span><span>        </span><span class="annot"><span class="annottext">IODeviceType
</span><a href="GHC.IO.Device.html#RegularFile"><span class="hs-identifier hs-var">RegularFile</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-265"></span><span>           </span><span class="hs-comment">-- On Windows we need an additional call to get a unique device id</span><span>
</span><span id="line-266"></span><span>           </span><span class="hs-comment">-- and inode, since fstat just returns 0 for both.</span><span>
</span><span id="line-267"></span><span>           </span><span class="hs-comment">-- See also Note [RTS File locking]</span><span>
</span><span id="line-268"></span><span>           </span><span class="hs-special">(</span><span id="local-6989586621679554972"><span class="annot"><span class="annottext">Word64
</span><a href="#local-6989586621679554972"><span class="hs-identifier hs-var">unique_dev</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679554971"><span class="annot"><span class="annottext">Word64
</span><a href="#local-6989586621679554971"><span class="hs-identifier hs-var">unique_ino</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CInt -&gt; CDev -&gt; CIno -&gt; IO (Word64, Word64)
</span><a href="GHC.IO.FD.html#getUniqueFileInfo"><span class="hs-identifier hs-var">getUniqueFileInfo</span></a></span><span> </span><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679554987"><span class="hs-identifier hs-var">fd</span></a></span><span> </span><span class="annot"><span class="annottext">CDev
</span><a href="#local-6989586621679554981"><span class="hs-identifier hs-var">dev</span></a></span><span> </span><span class="annot"><span class="annottext">CIno
</span><a href="#local-6989586621679554980"><span class="hs-identifier hs-var">ino</span></a></span><span>
</span><span id="line-269"></span><span>           </span><span id="local-6989586621679554969"><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679554969"><span class="hs-identifier hs-var">r</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Word64 -&gt; Word64 -&gt; Word64 -&gt; CInt -&gt; IO CInt
</span><a href="GHC.IO.FD.html#lockFile"><span class="hs-identifier hs-var">lockFile</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CInt -&gt; Word64
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679554987"><span class="hs-identifier hs-var">fd</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Word64
</span><a href="#local-6989586621679554972"><span class="hs-identifier hs-var">unique_dev</span></a></span><span> </span><span class="annot"><span class="annottext">Word64
</span><a href="#local-6989586621679554971"><span class="hs-identifier hs-var">unique_ino</span></a></span><span>
</span><span id="line-270"></span><span>                         </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool -&gt; CInt
forall a. Num a =&gt; Bool -&gt; a
</span><a href="Foreign.Marshal.Utils.html#fromBool"><span class="hs-identifier hs-var">fromBool</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679554977"><span class="hs-identifier hs-var">write</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-271"></span><span>           </span><span class="annot"><span class="annottext">Bool -&gt; IO () -&gt; IO ()
forall (f :: * -&gt; *). Applicative f =&gt; Bool -&gt; f () -&gt; f ()
</span><a href="GHC.Base.html#when"><span class="hs-identifier hs-var">when</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679554969"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="annot"><span class="annottext">CInt -&gt; CInt -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3D%3D"><span class="hs-operator hs-var">==</span></a></span><span> </span><span class="hs-glyph">-</span><span class="annot"><span class="annottext">CInt
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span>  </span><span class="annot"><span class="annottext">(IO () -&gt; IO ()) -&gt; IO () -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-272"></span><span>                </span><span class="annot"><span class="annottext">IOException -&gt; IO ()
forall a. IOException -&gt; IO a
</span><a href="GHC.IO.Exception.html#ioException"><span class="hs-identifier hs-var">ioException</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Maybe Handle
-&gt; IOErrorType
-&gt; String
-&gt; String
-&gt; Maybe CInt
-&gt; Maybe String
-&gt; IOException
</span><a href="GHC.IO.Exception.html#IOError"><span class="hs-identifier hs-var">IOError</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Handle
forall a. Maybe a
</span><a href="GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="annot"><span class="annottext">IOErrorType
</span><a href="GHC.IO.Exception.html#ResourceBusy"><span class="hs-identifier hs-var">ResourceBusy</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;openFile&quot;</span></span><span>
</span><span id="line-273"></span><span>                                   </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;file is locked&quot;</span></span><span> </span><span class="annot"><span class="annottext">Maybe CInt
forall a. Maybe a
</span><a href="GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe String
forall a. Maybe a
</span><a href="GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-274"></span><span>
</span><span id="line-275"></span><span>        </span><span id="local-6989586621679554965"><span class="annot"><span class="annottext">IODeviceType
</span><a href="#local-6989586621679554965"><span class="hs-identifier hs-var">_other_type</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">() -&gt; IO ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span class="hs-cpp">

#if defined(mingw32_HOST_OS)
</span><span>    </span><span class="annot"><span class="annottext">Bool -&gt; IO () -&gt; IO ()
forall (f :: * -&gt; *). Applicative f =&gt; Bool -&gt; f () -&gt; f ()
</span><a href="GHC.Base.html#when"><span class="hs-identifier hs-var">when</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#not"><span class="hs-identifier hs-var">not</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679554984"><span class="hs-identifier hs-var">is_socket</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(IO () -&gt; IO ()) -&gt; IO () -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">CInt -&gt; Bool -&gt; IO CInt
</span><a href="GHC.IO.FD.html#setmode"><span class="hs-identifier hs-var">setmode</span></a></span><span> </span><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679554987"><span class="hs-identifier hs-var">fd</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../ghc-prim/src/GHC.Types.html#True"><span class="hs-identifier hs-var">True</span></a></span><span> </span><span class="annot"><span class="annottext">IO CInt -&gt; IO () -&gt; IO ()
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; m b -&gt; m b
</span><a href="GHC.Base.html#%3E%3E"><span class="hs-operator hs-var">&gt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">() -&gt; IO ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span class="hs-cpp">
#endif
</span><span>
</span><span id="line-281"></span><span>    </span><span class="annot"><span class="annottext">(FD, IODeviceType) -&gt; IO (FD, IODeviceType)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FD :: CInt -&gt; Int -&gt; FD
</span><a href="GHC.IO.FD.html#FD"><span class="hs-identifier hs-type">FD</span></a></span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">fdFD :: CInt
</span><a href="GHC.IO.FD.html#fdFD"><span class="hs-identifier hs-var">fdFD</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679554987"><span class="hs-identifier hs-var">fd</span></a></span><span class="hs-special">,</span><span class="hs-cpp">
#if !defined(mingw32_HOST_OS)
</span><span>                </span><span class="hs-identifier">fdIsNonBlocking</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">fromEnum</span><span> </span><span class="hs-identifier">is_nonblock</span><span class="hs-cpp">
#else
</span><span>                </span><span class="annot"><span class="annottext">fdIsSocket_ :: Int
</span><a href="GHC.IO.FD.html#fdIsSocket_"><span class="hs-identifier hs-var">fdIsSocket_</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Int
forall a. Enum a =&gt; a -&gt; Int
</span><a href="GHC.Enum.html#fromEnum"><span class="hs-identifier hs-var">fromEnum</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679554984"><span class="hs-identifier hs-var">is_socket</span></a></span><span class="hs-cpp">
#endif
</span><span>              </span><span class="hs-special">}</span><span class="hs-special">,</span><span>
</span><span id="line-288"></span><span>            </span><span class="annot"><span class="annottext">IODeviceType
</span><a href="#local-6989586621679554982"><span class="hs-identifier hs-var">fd_type</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-289"></span><span>
</span><span id="line-290"></span><span class="annot"><a href="GHC.IO.FD.html#getUniqueFileInfo"><span class="hs-identifier hs-type">getUniqueFileInfo</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Foreign.C.Types.html#CInt"><span class="hs-identifier hs-type">CInt</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="System.Posix.Types.html#CDev"><span class="hs-identifier hs-type">CDev</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="System.Posix.Types.html#CIno"><span class="hs-identifier hs-type">CIno</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Word.html#Word64"><span class="hs-identifier hs-type">Word64</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Word.html#Word64"><span class="hs-identifier hs-type">Word64</span></a></span><span class="hs-special">)</span><span class="hs-cpp">
#if !defined(mingw32_HOST_OS)
</span><span class="hs-identifier">getUniqueFileInfo</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-identifier">dev</span><span> </span><span class="hs-identifier">ino</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">return</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">fromIntegral</span><span> </span><span class="hs-identifier">dev</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">fromIntegral</span><span> </span><span class="hs-identifier">ino</span><span class="hs-special">)</span><span class="hs-cpp">
#else
</span><span id="getUniqueFileInfo"><span class="annot"><span class="annottext">getUniqueFileInfo :: CInt -&gt; CDev -&gt; CIno -&gt; IO (Word64, Word64)
</span><a href="GHC.IO.FD.html#getUniqueFileInfo"><span class="hs-identifier hs-var hs-var">getUniqueFileInfo</span></a></span></span><span> </span><span id="local-6989586621679554961"><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679554961"><span class="hs-identifier hs-var">fd</span></a></span></span><span> </span><span class="annot"><span class="annottext">CDev
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">CIno
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-295"></span><span>  </span><span class="annot"><span class="annottext">Word64
-&gt; (Ptr Word64 -&gt; IO (Word64, Word64)) -&gt; IO (Word64, Word64)
forall a b. Storable a =&gt; a -&gt; (Ptr a -&gt; IO b) -&gt; IO b
</span><a href="Foreign.Marshal.Utils.html#with"><span class="hs-identifier hs-var">with</span></a></span><span> </span><span class="annot"><span class="annottext">Word64
</span><span class="hs-number">0</span></span><span> </span><span class="annot"><span class="annottext">((Ptr Word64 -&gt; IO (Word64, Word64)) -&gt; IO (Word64, Word64))
-&gt; (Ptr Word64 -&gt; IO (Word64, Word64)) -&gt; IO (Word64, Word64)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679554959"><span class="annot"><span class="annottext">Ptr Word64
</span><a href="#local-6989586621679554959"><span class="hs-identifier hs-var">devptr</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-296"></span><span>    </span><span class="annot"><span class="annottext">Word64
-&gt; (Ptr Word64 -&gt; IO (Word64, Word64)) -&gt; IO (Word64, Word64)
forall a b. Storable a =&gt; a -&gt; (Ptr a -&gt; IO b) -&gt; IO b
</span><a href="Foreign.Marshal.Utils.html#with"><span class="hs-identifier hs-var">with</span></a></span><span> </span><span class="annot"><span class="annottext">Word64
</span><span class="hs-number">0</span></span><span> </span><span class="annot"><span class="annottext">((Ptr Word64 -&gt; IO (Word64, Word64)) -&gt; IO (Word64, Word64))
-&gt; (Ptr Word64 -&gt; IO (Word64, Word64)) -&gt; IO (Word64, Word64)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679554958"><span class="annot"><span class="annottext">Ptr Word64
</span><a href="#local-6989586621679554958"><span class="hs-identifier hs-var">inoptr</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-297"></span><span>      </span><span class="annot"><span class="annottext">CInt -&gt; Ptr Word64 -&gt; Ptr Word64 -&gt; IO ()
</span><a href="GHC.IO.FD.html#c_getUniqueFileInfo"><span class="hs-identifier hs-var">c_getUniqueFileInfo</span></a></span><span> </span><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679554961"><span class="hs-identifier hs-var">fd</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word64
</span><a href="#local-6989586621679554959"><span class="hs-identifier hs-var">devptr</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word64
</span><a href="#local-6989586621679554958"><span class="hs-identifier hs-var">inoptr</span></a></span><span>
</span><span id="line-298"></span><span>      </span><span class="annot"><span class="annottext">(Word64 -&gt; Word64 -&gt; (Word64, Word64))
-&gt; IO Word64 -&gt; IO Word64 -&gt; IO (Word64, Word64)
forall (m :: * -&gt; *) a1 a2 r.
Monad m =&gt;
(a1 -&gt; a2 -&gt; r) -&gt; m a1 -&gt; m a2 -&gt; m r
</span><a href="GHC.Base.html#liftM2"><span class="hs-identifier hs-var">liftM2</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">,</span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Ptr Word64 -&gt; IO Word64
forall a. Storable a =&gt; Ptr a -&gt; IO a
</span><a href="Foreign.Storable.html#peek"><span class="hs-identifier hs-var">peek</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word64
</span><a href="#local-6989586621679554959"><span class="hs-identifier hs-var">devptr</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Ptr Word64 -&gt; IO Word64
forall a. Storable a =&gt; Ptr a -&gt; IO a
</span><a href="Foreign.Storable.html#peek"><span class="hs-identifier hs-var">peek</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word64
</span><a href="#local-6989586621679554958"><span class="hs-identifier hs-var">inoptr</span></a></span><span class="hs-special">)</span><span class="hs-cpp">
#endif
</span><span class="hs-cpp">
#if defined(mingw32_HOST_OS)
</span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="annot"><span class="hs-keyword">ccall</span></span><span> </span><span class="annot"><span class="hs-keyword">unsafe</span></span><span> </span><span class="annot"><span class="hs-string">&quot;__hscore_setmode&quot;</span></span><span>
</span><span id="line-303"></span><span>  </span><span id="setmode"><span class="annot"><a href="GHC.IO.FD.html#setmode"><span class="hs-identifier hs-var">setmode</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Foreign.C.Types.html#CInt"><span class="hs-identifier hs-type">CInt</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Bool"><span class="hs-identifier hs-type">Bool</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="Foreign.C.Types.html#CInt"><span class="hs-identifier hs-type">CInt</span></a></span><span class="hs-cpp">
#endif
</span><span>
</span><span id="line-306"></span><span class="hs-comment">-- -----------------------------------------------------------------------------</span><span>
</span><span id="line-307"></span><span class="hs-comment">-- Standard file descriptors</span><span>
</span><span id="line-308"></span><span>
</span><span id="line-309"></span><span class="annot"><a href="GHC.IO.FD.html#stdFD"><span class="hs-identifier hs-type">stdFD</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Foreign.C.Types.html#CInt"><span class="hs-identifier hs-type">CInt</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.IO.FD.html#FD"><span class="hs-identifier hs-type">FD</span></a></span><span>
</span><span id="line-310"></span><span id="stdFD"><span class="annot"><span class="annottext">stdFD :: CInt -&gt; FD
</span><a href="GHC.IO.FD.html#stdFD"><span class="hs-identifier hs-var hs-var">stdFD</span></a></span></span><span> </span><span id="local-6989586621679554953"><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679554953"><span class="hs-identifier hs-var">fd</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FD :: CInt -&gt; Int -&gt; FD
</span><a href="GHC.IO.FD.html#FD"><span class="hs-identifier hs-type">FD</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">fdFD :: CInt
</span><a href="GHC.IO.FD.html#fdFD"><span class="hs-identifier hs-var">fdFD</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679554953"><span class="hs-identifier hs-var">fd</span></a></span><span class="hs-special">,</span><span class="hs-cpp">
#if defined(mingw32_HOST_OS)
</span><span>                </span><span class="annot"><span class="annottext">fdIsSocket_ :: Int
</span><a href="GHC.IO.FD.html#fdIsSocket_"><span class="hs-identifier hs-var">fdIsSocket_</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span class="hs-cpp">
#else
</span><span>                </span><span class="hs-identifier">fdIsNonBlocking</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-number">0</span><span>
</span><span id="line-315"></span><span>   </span><span class="hs-comment">-- We don't set non-blocking mode on standard handles, because it may</span><span>
</span><span id="line-316"></span><span>   </span><span class="hs-comment">-- confuse other applications attached to the same TTY/pipe</span><span>
</span><span id="line-317"></span><span>   </span><span class="hs-comment">-- see Note [nonblock]</span><span class="hs-cpp">
#endif
</span><span>                </span><span class="hs-special">}</span><span>
</span><span id="line-320"></span><span>
</span><span id="line-321"></span><span class="annot"><a href="GHC.IO.FD.html#stdin"><span class="hs-identifier hs-type">stdin</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.FD.html#stdout"><span class="hs-identifier hs-type">stdout</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.FD.html#stderr"><span class="hs-identifier hs-type">stderr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.FD.html#FD"><span class="hs-identifier hs-type">FD</span></a></span><span>
</span><span id="line-322"></span><span id="stdin"><span class="annot"><span class="annottext">stdin :: FD
</span><a href="GHC.IO.FD.html#stdin"><span class="hs-identifier hs-var hs-var">stdin</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CInt -&gt; FD
</span><a href="GHC.IO.FD.html#stdFD"><span class="hs-identifier hs-var">stdFD</span></a></span><span> </span><span class="annot"><span class="annottext">CInt
</span><span class="hs-number">0</span></span><span>
</span><span id="line-323"></span><span id="stdout"><span class="annot"><span class="annottext">stdout :: FD
</span><a href="GHC.IO.FD.html#stdout"><span class="hs-identifier hs-var hs-var">stdout</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CInt -&gt; FD
</span><a href="GHC.IO.FD.html#stdFD"><span class="hs-identifier hs-var">stdFD</span></a></span><span> </span><span class="annot"><span class="annottext">CInt
</span><span class="hs-number">1</span></span><span>
</span><span id="line-324"></span><span id="stderr"><span class="annot"><span class="annottext">stderr :: FD
</span><a href="GHC.IO.FD.html#stderr"><span class="hs-identifier hs-var hs-var">stderr</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CInt -&gt; FD
</span><a href="GHC.IO.FD.html#stdFD"><span class="hs-identifier hs-var">stdFD</span></a></span><span> </span><span class="annot"><span class="annottext">CInt
</span><span class="hs-number">2</span></span><span>
</span><span id="line-325"></span><span>
</span><span id="line-326"></span><span class="hs-comment">-- -----------------------------------------------------------------------------</span><span>
</span><span id="line-327"></span><span class="hs-comment">-- Operations on file descriptors</span><span>
</span><span id="line-328"></span><span>
</span><span id="line-329"></span><span class="annot"><a href="GHC.IO.FD.html#close"><span class="hs-identifier hs-type">close</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.FD.html#FD"><span class="hs-identifier hs-type">FD</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-330"></span><span id="close"><span class="annot"><span class="annottext">close :: FD -&gt; IO ()
</span><a href="GHC.IO.FD.html#close"><span class="hs-identifier hs-var hs-var">close</span></a></span></span><span> </span><span id="local-6989586621679554952"><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679554952"><span class="hs-identifier hs-var">fd</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-331"></span><span>  </span><span class="hs-keyword">do</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679554944"><span class="annot"><span class="annottext">closer :: a -&gt; IO ()
</span><a href="#local-6989586621679554944"><span class="hs-identifier hs-var hs-var">closer</span></a></span></span><span> </span><span id="local-6989586621679554943"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679554943"><span class="hs-identifier hs-var">realFd</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-332"></span><span>           </span><span class="annot"><span class="annottext">String -&gt; IO CInt -&gt; IO ()
forall a. (Eq a, Num a) =&gt; String -&gt; IO a -&gt; IO ()
</span><a href="Foreign.C.Error.html#throwErrnoIfMinus1Retry_"><span class="hs-identifier hs-var">throwErrnoIfMinus1Retry_</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;GHC.IO.FD.close&quot;</span></span><span> </span><span class="annot"><span class="annottext">(IO CInt -&gt; IO ()) -&gt; IO CInt -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span class="hs-cpp">
#if defined(mingw32_HOST_OS)
</span><span>           </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">FD -&gt; Bool
</span><a href="GHC.IO.FD.html#fdIsSocket"><span class="hs-identifier hs-var">fdIsSocket</span></a></span><span> </span><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679554952"><span class="hs-identifier hs-var">fd</span></a></span><span> </span><span class="hs-keyword">then</span><span>
</span><span id="line-335"></span><span>             </span><span class="annot"><span class="annottext">CInt -&gt; IO CInt
</span><a href="GHC.IO.FD.html#c_closesocket"><span class="hs-identifier hs-var">c_closesocket</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a -&gt; CInt
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679554943"><span class="hs-identifier hs-var">realFd</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-336"></span><span>           </span><span class="hs-keyword">else</span><span class="hs-cpp">
#endif
</span><span>             </span><span class="annot"><span class="annottext">CInt -&gt; IO CInt
</span><a href="System.Posix.Internals.html#c_close"><span class="hs-identifier hs-var">c_close</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a -&gt; CInt
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679554943"><span class="hs-identifier hs-var">realFd</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-339"></span><span>
</span><span id="line-340"></span><span>     </span><span class="hs-comment">-- release the lock *first*, because otherwise if we're preempted</span><span>
</span><span id="line-341"></span><span>     </span><span class="hs-comment">-- after closing but before releasing, the FD may have been reused.</span><span>
</span><span id="line-342"></span><span>     </span><span class="hs-comment">-- (#7646)</span><span>
</span><span id="line-343"></span><span>     </span><span class="annot"><span class="annottext">FD -&gt; IO ()
</span><a href="GHC.IO.FD.html#release"><span class="hs-identifier hs-var">release</span></a></span><span> </span><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679554952"><span class="hs-identifier hs-var">fd</span></a></span><span>
</span><span id="line-344"></span><span>
</span><span id="line-345"></span><span>     </span><span class="annot"><span class="annottext">(Fd -&gt; IO ()) -&gt; Fd -&gt; IO ()
</span><a href="GHC.Conc.IO.html#closeFdWith"><span class="hs-identifier hs-var">closeFdWith</span></a></span><span> </span><span class="annot"><span class="annottext">Fd -&gt; IO ()
forall {a}. Integral a =&gt; a -&gt; IO ()
</span><a href="#local-6989586621679554944"><span class="hs-identifier hs-var">closer</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CInt -&gt; Fd
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FD -&gt; CInt
</span><a href="GHC.IO.FD.html#fdFD"><span class="hs-identifier hs-var hs-var">fdFD</span></a></span><span> </span><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679554952"><span class="hs-identifier hs-var">fd</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-346"></span><span>
</span><span id="line-347"></span><span class="annot"><a href="GHC.IO.FD.html#release"><span class="hs-identifier hs-type">release</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.FD.html#FD"><span class="hs-identifier hs-type">FD</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-348"></span><span id="release"><span class="annot"><span class="annottext">release :: FD -&gt; IO ()
</span><a href="GHC.IO.FD.html#release"><span class="hs-identifier hs-var hs-var">release</span></a></span></span><span> </span><span id="local-6989586621679554939"><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679554939"><span class="hs-identifier hs-var">fd</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="annot"><span class="annottext">CInt
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Word64 -&gt; IO CInt
</span><a href="GHC.IO.FD.html#unlockFile"><span class="hs-identifier hs-var">unlockFile</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CInt -&gt; Word64
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">(CInt -&gt; Word64) -&gt; CInt -&gt; Word64
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">FD -&gt; CInt
</span><a href="GHC.IO.FD.html#fdFD"><span class="hs-identifier hs-var hs-var">fdFD</span></a></span><span> </span><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679554939"><span class="hs-identifier hs-var">fd</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-349"></span><span>                </span><span class="annot"><span class="annottext">() -&gt; IO ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span class="hs-cpp">

#if defined(mingw32_HOST_OS)
</span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-keyword">unsafe</span><span> </span><span class="hs-string">&quot;HsBase.h closesocket&quot;</span><span>
</span><span id="line-353"></span><span>   </span><span id="c_closesocket"><span class="annot"><a href="GHC.IO.FD.html#c_closesocket"><span class="hs-identifier hs-var">c_closesocket</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Foreign.C.Types.html#CInt"><span class="hs-identifier hs-type">CInt</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="Foreign.C.Types.html#CInt"><span class="hs-identifier hs-type">CInt</span></a></span><span class="hs-cpp">
#endif
</span><span>
</span><span id="line-356"></span><span class="annot"><a href="GHC.IO.FD.html#isSeekable"><span class="hs-identifier hs-type">isSeekable</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.FD.html#FD"><span class="hs-identifier hs-type">FD</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Bool"><span class="hs-identifier hs-type">Bool</span></a></span><span>
</span><span id="line-357"></span><span id="isSeekable"><span class="annot"><span class="annottext">isSeekable :: FD -&gt; IO Bool
</span><a href="GHC.IO.FD.html#isSeekable"><span class="hs-identifier hs-var hs-var">isSeekable</span></a></span></span><span> </span><span id="local-6989586621679554937"><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679554937"><span class="hs-identifier hs-var">fd</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-358"></span><span>  </span><span id="local-6989586621679554936"><span class="annot"><span class="annottext">IODeviceType
</span><a href="#local-6989586621679554936"><span class="hs-identifier hs-var">t</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FD -&gt; IO IODeviceType
</span><a href="GHC.IO.FD.html#devType"><span class="hs-identifier hs-var">devType</span></a></span><span> </span><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679554937"><span class="hs-identifier hs-var">fd</span></a></span><span>
</span><span id="line-359"></span><span>  </span><span class="annot"><span class="annottext">Bool -&gt; IO Bool
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IODeviceType
</span><a href="#local-6989586621679554936"><span class="hs-identifier hs-var">t</span></a></span><span> </span><span class="annot"><span class="annottext">IODeviceType -&gt; IODeviceType -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3D%3D"><span class="hs-operator hs-var">==</span></a></span><span> </span><span class="annot"><span class="annottext">IODeviceType
</span><a href="GHC.IO.Device.html#RegularFile"><span class="hs-identifier hs-var">RegularFile</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%7C%7C"><span class="hs-operator hs-var">||</span></a></span><span> </span><span class="annot"><span class="annottext">IODeviceType
</span><a href="#local-6989586621679554936"><span class="hs-identifier hs-var">t</span></a></span><span> </span><span class="annot"><span class="annottext">IODeviceType -&gt; IODeviceType -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3D%3D"><span class="hs-operator hs-var">==</span></a></span><span> </span><span class="annot"><span class="annottext">IODeviceType
</span><a href="GHC.IO.Device.html#RawDevice"><span class="hs-identifier hs-var">RawDevice</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-360"></span><span>
</span><span id="line-361"></span><span class="annot"><a href="GHC.IO.FD.html#seek"><span class="hs-identifier hs-type">seek</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.FD.html#FD"><span class="hs-identifier hs-type">FD</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.IO.Device.html#SeekMode"><span class="hs-identifier hs-type">SeekMode</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-bignum/src/GHC.Num.Integer.html#Integer"><span class="hs-identifier hs-type">Integer</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="../../ghc-bignum/src/GHC.Num.Integer.html#Integer"><span class="hs-identifier hs-type">Integer</span></a></span><span>
</span><span id="line-362"></span><span id="seek"><span class="annot"><span class="annottext">seek :: FD -&gt; SeekMode -&gt; Integer -&gt; IO Integer
</span><a href="GHC.IO.FD.html#seek"><span class="hs-identifier hs-var hs-var">seek</span></a></span></span><span> </span><span id="local-6989586621679554933"><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679554933"><span class="hs-identifier hs-var">fd</span></a></span></span><span> </span><span id="local-6989586621679554932"><span class="annot"><span class="annottext">SeekMode
</span><a href="#local-6989586621679554932"><span class="hs-identifier hs-var">mode</span></a></span></span><span> </span><span id="local-6989586621679554931"><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679554931"><span class="hs-identifier hs-var">off</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">COff -&gt; Integer
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">(COff -&gt; Integer) -&gt; IO COff -&gt; IO Integer
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="GHC.Base.html#fmap"><span class="hs-operator hs-var">`fmap`</span></a></span><span>
</span><span id="line-363"></span><span>  </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; IO COff -&gt; IO COff
forall a. (Eq a, Num a) =&gt; String -&gt; IO a -&gt; IO a
</span><a href="Foreign.C.Error.html#throwErrnoIfMinus1Retry"><span class="hs-identifier hs-var">throwErrnoIfMinus1Retry</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;seek&quot;</span></span><span> </span><span class="annot"><span class="annottext">(IO COff -&gt; IO COff) -&gt; IO COff -&gt; IO COff
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-364"></span><span>     </span><span class="annot"><span class="annottext">CInt -&gt; COff -&gt; CInt -&gt; IO COff
</span><a href="System.Posix.Internals.html#c_lseek"><span class="hs-identifier hs-var">c_lseek</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FD -&gt; CInt
</span><a href="GHC.IO.FD.html#fdFD"><span class="hs-identifier hs-var hs-var">fdFD</span></a></span><span> </span><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679554933"><span class="hs-identifier hs-var">fd</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Integer -&gt; COff
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679554931"><span class="hs-identifier hs-var">off</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679554929"><span class="hs-identifier hs-var">seektype</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-365"></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-366"></span><span>    </span><span class="annot"><a href="#local-6989586621679554929"><span class="hs-identifier hs-type">seektype</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Foreign.C.Types.html#CInt"><span class="hs-identifier hs-type">CInt</span></a></span><span>
</span><span id="line-367"></span><span>    </span><span id="local-6989586621679554929"><span class="annot"><span class="annottext">seektype :: CInt
</span><a href="#local-6989586621679554929"><span class="hs-identifier hs-var hs-var">seektype</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">SeekMode
</span><a href="#local-6989586621679554932"><span class="hs-identifier hs-var">mode</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-368"></span><span>                   </span><span class="annot"><span class="annottext">SeekMode
</span><a href="GHC.IO.Device.html#AbsoluteSeek"><span class="hs-identifier hs-var">AbsoluteSeek</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CInt
</span><a href="System.Posix.Internals.html#sEEK_SET"><span class="hs-identifier hs-var">sEEK_SET</span></a></span><span>
</span><span id="line-369"></span><span>                   </span><span class="annot"><span class="annottext">SeekMode
</span><a href="GHC.IO.Device.html#RelativeSeek"><span class="hs-identifier hs-var">RelativeSeek</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CInt
</span><a href="System.Posix.Internals.html#sEEK_CUR"><span class="hs-identifier hs-var">sEEK_CUR</span></a></span><span>
</span><span id="line-370"></span><span>                   </span><span class="annot"><span class="annottext">SeekMode
</span><a href="GHC.IO.Device.html#SeekFromEnd"><span class="hs-identifier hs-var">SeekFromEnd</span></a></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CInt
</span><a href="System.Posix.Internals.html#sEEK_END"><span class="hs-identifier hs-var">sEEK_END</span></a></span><span>
</span><span id="line-371"></span><span>
</span><span id="line-372"></span><span class="annot"><a href="GHC.IO.FD.html#tell"><span class="hs-identifier hs-type">tell</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.FD.html#FD"><span class="hs-identifier hs-type">FD</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="../../ghc-bignum/src/GHC.Num.Integer.html#Integer"><span class="hs-identifier hs-type">Integer</span></a></span><span>
</span><span id="line-373"></span><span id="tell"><span class="annot"><span class="annottext">tell :: FD -&gt; IO Integer
</span><a href="GHC.IO.FD.html#tell"><span class="hs-identifier hs-var hs-var">tell</span></a></span></span><span> </span><span id="local-6989586621679554922"><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679554922"><span class="hs-identifier hs-var">fd</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-374"></span><span> </span><span class="annot"><span class="annottext">COff -&gt; Integer
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">(COff -&gt; Integer) -&gt; IO COff -&gt; IO Integer
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="GHC.Base.html#fmap"><span class="hs-operator hs-var">`fmap`</span></a></span><span>
</span><span id="line-375"></span><span>   </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; IO COff -&gt; IO COff
forall a. (Eq a, Num a) =&gt; String -&gt; IO a -&gt; IO a
</span><a href="Foreign.C.Error.html#throwErrnoIfMinus1Retry"><span class="hs-identifier hs-var">throwErrnoIfMinus1Retry</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;hGetPosn&quot;</span></span><span> </span><span class="annot"><span class="annottext">(IO COff -&gt; IO COff) -&gt; IO COff -&gt; IO COff
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-376"></span><span>      </span><span class="annot"><span class="annottext">CInt -&gt; COff -&gt; CInt -&gt; IO COff
</span><a href="System.Posix.Internals.html#c_lseek"><span class="hs-identifier hs-var">c_lseek</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FD -&gt; CInt
</span><a href="GHC.IO.FD.html#fdFD"><span class="hs-identifier hs-var hs-var">fdFD</span></a></span><span> </span><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679554922"><span class="hs-identifier hs-var">fd</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">COff
</span><span class="hs-number">0</span></span><span> </span><span class="annot"><span class="annottext">CInt
</span><a href="System.Posix.Internals.html#sEEK_CUR"><span class="hs-identifier hs-var">sEEK_CUR</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-377"></span><span>
</span><span id="line-378"></span><span class="annot"><a href="GHC.IO.FD.html#getSize"><span class="hs-identifier hs-type">getSize</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.FD.html#FD"><span class="hs-identifier hs-type">FD</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="../../ghc-bignum/src/GHC.Num.Integer.html#Integer"><span class="hs-identifier hs-type">Integer</span></a></span><span>
</span><span id="line-379"></span><span id="getSize"><span class="annot"><span class="annottext">getSize :: FD -&gt; IO Integer
</span><a href="GHC.IO.FD.html#getSize"><span class="hs-identifier hs-var hs-var">getSize</span></a></span></span><span> </span><span id="local-6989586621679554921"><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679554921"><span class="hs-identifier hs-var">fd</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CInt -&gt; IO Integer
</span><a href="System.Posix.Internals.html#fdFileSize"><span class="hs-identifier hs-var">fdFileSize</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FD -&gt; CInt
</span><a href="GHC.IO.FD.html#fdFD"><span class="hs-identifier hs-var hs-var">fdFD</span></a></span><span> </span><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679554921"><span class="hs-identifier hs-var">fd</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-380"></span><span>
</span><span id="line-381"></span><span class="annot"><a href="GHC.IO.FD.html#setSize"><span class="hs-identifier hs-type">setSize</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.FD.html#FD"><span class="hs-identifier hs-type">FD</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-bignum/src/GHC.Num.Integer.html#Integer"><span class="hs-identifier hs-type">Integer</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-382"></span><span id="setSize"><span class="annot"><span class="annottext">setSize :: FD -&gt; Integer -&gt; IO ()
</span><a href="GHC.IO.FD.html#setSize"><span class="hs-identifier hs-var hs-var">setSize</span></a></span></span><span> </span><span id="local-6989586621679554919"><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679554919"><span class="hs-identifier hs-var">fd</span></a></span></span><span> </span><span id="local-6989586621679554918"><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679554918"><span class="hs-identifier hs-var">size</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-383"></span><span>  </span><span class="annot"><span class="annottext">(CInt -&gt; Bool) -&gt; String -&gt; IO CInt -&gt; IO ()
forall a. (a -&gt; Bool) -&gt; String -&gt; IO a -&gt; IO ()
</span><a href="Foreign.C.Error.html#throwErrnoIf_"><span class="hs-identifier hs-var">throwErrnoIf_</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CInt -&gt; CInt -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%2F%3D"><span class="hs-operator hs-var">/=</span></a></span><span class="annot"><span class="annottext">CInt
</span><span class="hs-number">0</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;GHC.IO.FD.setSize&quot;</span></span><span>  </span><span class="annot"><span class="annottext">(IO CInt -&gt; IO ()) -&gt; IO CInt -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-384"></span><span>     </span><span class="annot"><span class="annottext">CInt -&gt; COff -&gt; IO CInt
</span><a href="System.Posix.Internals.html#c_ftruncate"><span class="hs-identifier hs-var">c_ftruncate</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FD -&gt; CInt
</span><a href="GHC.IO.FD.html#fdFD"><span class="hs-identifier hs-var hs-var">fdFD</span></a></span><span> </span><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679554919"><span class="hs-identifier hs-var">fd</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Integer -&gt; COff
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679554918"><span class="hs-identifier hs-var">size</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-385"></span><span>
</span><span id="line-386"></span><span class="annot"><a href="GHC.IO.FD.html#devType"><span class="hs-identifier hs-type">devType</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.FD.html#FD"><span class="hs-identifier hs-type">FD</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="GHC.IO.Device.html#IODeviceType"><span class="hs-identifier hs-type">IODeviceType</span></a></span><span>
</span><span id="line-387"></span><span id="devType"><span class="annot"><span class="annottext">devType :: FD -&gt; IO IODeviceType
</span><a href="GHC.IO.FD.html#devType"><span class="hs-identifier hs-var hs-var">devType</span></a></span></span><span> </span><span id="local-6989586621679554915"><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679554915"><span class="hs-identifier hs-var">fd</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">(</span><span id="local-6989586621679554914"><span class="annot"><span class="annottext">IODeviceType
</span><a href="#local-6989586621679554914"><span class="hs-identifier hs-var">ty</span></a></span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">CDev
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">CIno
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CInt -&gt; IO (IODeviceType, CDev, CIno)
</span><a href="System.Posix.Internals.html#fdStat"><span class="hs-identifier hs-var">fdStat</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FD -&gt; CInt
</span><a href="GHC.IO.FD.html#fdFD"><span class="hs-identifier hs-var hs-var">fdFD</span></a></span><span> </span><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679554915"><span class="hs-identifier hs-var">fd</span></a></span><span class="hs-special">)</span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">IODeviceType -&gt; IO IODeviceType
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">IODeviceType
</span><a href="#local-6989586621679554914"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-388"></span><span>
</span><span id="line-389"></span><span class="annot"><a href="GHC.IO.FD.html#dup"><span class="hs-identifier hs-type">dup</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.FD.html#FD"><span class="hs-identifier hs-type">FD</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="GHC.IO.FD.html#FD"><span class="hs-identifier hs-type">FD</span></a></span><span>
</span><span id="line-390"></span><span id="dup"><span class="annot"><span class="annottext">dup :: FD -&gt; IO FD
</span><a href="GHC.IO.FD.html#dup"><span class="hs-identifier hs-var hs-var">dup</span></a></span></span><span> </span><span id="local-6989586621679554913"><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679554913"><span class="hs-identifier hs-var">fd</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-391"></span><span>  </span><span id="local-6989586621679554912"><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679554912"><span class="hs-identifier hs-var">newfd</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">String -&gt; IO CInt -&gt; IO CInt
forall a. (Eq a, Num a) =&gt; String -&gt; IO a -&gt; IO a
</span><a href="Foreign.C.Error.html#throwErrnoIfMinus1"><span class="hs-identifier hs-var">throwErrnoIfMinus1</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;GHC.IO.FD.dup&quot;</span></span><span> </span><span class="annot"><span class="annottext">(IO CInt -&gt; IO CInt) -&gt; IO CInt -&gt; IO CInt
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">CInt -&gt; IO CInt
</span><a href="System.Posix.Internals.html#c_dup"><span class="hs-identifier hs-var">c_dup</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FD -&gt; CInt
</span><a href="GHC.IO.FD.html#fdFD"><span class="hs-identifier hs-var hs-var">fdFD</span></a></span><span> </span><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679554913"><span class="hs-identifier hs-var">fd</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-392"></span><span>  </span><span class="annot"><span class="annottext">FD -&gt; IO FD
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679554913"><span class="hs-identifier hs-var">fd</span></a></span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">fdFD :: CInt
</span><a href="GHC.IO.FD.html#fdFD"><span class="hs-identifier hs-var">fdFD</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679554912"><span class="hs-identifier hs-var">newfd</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-393"></span><span>
</span><span id="line-394"></span><span class="annot"><a href="GHC.IO.FD.html#dup2"><span class="hs-identifier hs-type">dup2</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.FD.html#FD"><span class="hs-identifier hs-type">FD</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.IO.FD.html#FD"><span class="hs-identifier hs-type">FD</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="GHC.IO.FD.html#FD"><span class="hs-identifier hs-type">FD</span></a></span><span>
</span><span id="line-395"></span><span id="dup2"><span class="annot"><span class="annottext">dup2 :: FD -&gt; FD -&gt; IO FD
</span><a href="GHC.IO.FD.html#dup2"><span class="hs-identifier hs-var hs-var">dup2</span></a></span></span><span> </span><span id="local-6989586621679554909"><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679554909"><span class="hs-identifier hs-var">fd</span></a></span></span><span> </span><span id="local-6989586621679554908"><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679554908"><span class="hs-identifier hs-var">fdto</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-396"></span><span>  </span><span class="hs-comment">-- Windows' dup2 does not return the new descriptor, unlike Unix</span><span>
</span><span id="line-397"></span><span>  </span><span class="annot"><span class="annottext">String -&gt; IO CInt -&gt; IO ()
forall a. (Eq a, Num a) =&gt; String -&gt; IO a -&gt; IO ()
</span><a href="Foreign.C.Error.html#throwErrnoIfMinus1_"><span class="hs-identifier hs-var">throwErrnoIfMinus1_</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;GHC.IO.FD.dup2&quot;</span></span><span> </span><span class="annot"><span class="annottext">(IO CInt -&gt; IO ()) -&gt; IO CInt -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-398"></span><span>    </span><span class="annot"><span class="annottext">CInt -&gt; CInt -&gt; IO CInt
</span><a href="System.Posix.Internals.html#c_dup2"><span class="hs-identifier hs-var">c_dup2</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FD -&gt; CInt
</span><a href="GHC.IO.FD.html#fdFD"><span class="hs-identifier hs-var hs-var">fdFD</span></a></span><span> </span><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679554909"><span class="hs-identifier hs-var">fd</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FD -&gt; CInt
</span><a href="GHC.IO.FD.html#fdFD"><span class="hs-identifier hs-var hs-var">fdFD</span></a></span><span> </span><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679554908"><span class="hs-identifier hs-var">fdto</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-399"></span><span>  </span><span class="annot"><span class="annottext">FD -&gt; IO FD
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679554909"><span class="hs-identifier hs-var">fd</span></a></span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">fdFD :: CInt
</span><a href="GHC.IO.FD.html#fdFD"><span class="hs-identifier hs-var">fdFD</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FD -&gt; CInt
</span><a href="GHC.IO.FD.html#fdFD"><span class="hs-identifier hs-var hs-var">fdFD</span></a></span><span> </span><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679554908"><span class="hs-identifier hs-var">fdto</span></a></span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-comment">-- original FD, with the new fdFD</span><span>
</span><span id="line-400"></span><span>
</span><span id="line-401"></span><span class="annot"><a href="GHC.IO.FD.html#setNonBlockingMode"><span class="hs-identifier hs-type">setNonBlockingMode</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.FD.html#FD"><span class="hs-identifier hs-type">FD</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Bool"><span class="hs-identifier hs-type">Bool</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="GHC.IO.FD.html#FD"><span class="hs-identifier hs-type">FD</span></a></span><span>
</span><span id="line-402"></span><span id="setNonBlockingMode"><span class="annot"><span class="annottext">setNonBlockingMode :: FD -&gt; Bool -&gt; IO FD
</span><a href="GHC.IO.FD.html#setNonBlockingMode"><span class="hs-identifier hs-var hs-var">setNonBlockingMode</span></a></span></span><span> </span><span id="local-6989586621679554905"><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679554905"><span class="hs-identifier hs-var">fd</span></a></span></span><span> </span><span id="local-6989586621679554904"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679554904"><span class="hs-identifier hs-var">set</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-403"></span><span>  </span><span class="annot"><span class="annottext">CInt -&gt; Bool -&gt; IO ()
</span><a href="System.Posix.Internals.html#setNonBlockingFD"><span class="hs-identifier hs-var">setNonBlockingFD</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FD -&gt; CInt
</span><a href="GHC.IO.FD.html#fdFD"><span class="hs-identifier hs-var hs-var">fdFD</span></a></span><span> </span><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679554905"><span class="hs-identifier hs-var">fd</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679554904"><span class="hs-identifier hs-var">set</span></a></span><span class="hs-cpp">
#if defined(mingw32_HOST_OS)
</span><span>  </span><span class="annot"><span class="annottext">FD -&gt; IO FD
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679554905"><span class="hs-identifier hs-var">fd</span></a></span><span class="hs-cpp">
#else
</span><span>  </span><span class="hs-identifier">return</span><span> </span><span class="hs-identifier">fd</span><span class="hs-special">{</span><span> </span><span class="hs-identifier">fdIsNonBlocking</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">fromEnum</span><span> </span><span class="hs-identifier">set</span><span> </span><span class="hs-special">}</span><span class="hs-cpp">
#endif
</span><span>
</span><span id="line-410"></span><span class="annot"><a href="GHC.IO.FD.html#ready"><span class="hs-identifier hs-type">ready</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.FD.html#FD"><span class="hs-identifier hs-type">FD</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Bool"><span class="hs-identifier hs-type">Bool</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Bool"><span class="hs-identifier hs-type">Bool</span></a></span><span>
</span><span id="line-411"></span><span id="ready"><span class="annot"><span class="annottext">ready :: FD -&gt; Bool -&gt; Int -&gt; IO Bool
</span><a href="GHC.IO.FD.html#ready"><span class="hs-identifier hs-var hs-var">ready</span></a></span></span><span> </span><span id="local-6989586621679554902"><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679554902"><span class="hs-identifier hs-var">fd</span></a></span></span><span> </span><span id="local-6989586621679554901"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679554901"><span class="hs-identifier hs-var">write</span></a></span></span><span> </span><span id="local-6989586621679554900"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679554900"><span class="hs-identifier hs-var">msecs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-412"></span><span>  </span><span id="local-6989586621679554899"><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679554899"><span class="hs-identifier hs-var">r</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">String -&gt; IO CInt -&gt; IO CInt
forall a. (Eq a, Num a) =&gt; String -&gt; IO a -&gt; IO a
</span><a href="Foreign.C.Error.html#throwErrnoIfMinus1Retry"><span class="hs-identifier hs-var">throwErrnoIfMinus1Retry</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;GHC.IO.FD.ready&quot;</span></span><span> </span><span class="annot"><span class="annottext">(IO CInt -&gt; IO CInt) -&gt; IO CInt -&gt; IO CInt
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-413"></span><span>          </span><span class="annot"><span class="annottext">CInt -&gt; CBool -&gt; Int64 -&gt; CBool -&gt; IO CInt
</span><a href="GHC.IO.FD.html#fdReady"><span class="hs-identifier hs-var">fdReady</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FD -&gt; CInt
</span><a href="GHC.IO.FD.html#fdFD"><span class="hs-identifier hs-var hs-var">fdFD</span></a></span><span> </span><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679554902"><span class="hs-identifier hs-var">fd</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; CBool
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">(Int -&gt; CBool) -&gt; Int -&gt; CBool
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Int
forall a. Enum a =&gt; a -&gt; Int
</span><a href="GHC.Enum.html#fromEnum"><span class="hs-identifier hs-var">fromEnum</span></a></span><span> </span><span class="annot"><span class="annottext">(Bool -&gt; Int) -&gt; Bool -&gt; Int
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679554901"><span class="hs-identifier hs-var">write</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-414"></span><span>                            </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; Int64
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679554900"><span class="hs-identifier hs-var">msecs</span></a></span><span class="hs-special">)</span><span class="hs-cpp">
#if defined(mingw32_HOST_OS)
</span><span>                          </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; CBool
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">(Int -&gt; CBool) -&gt; Int -&gt; CBool
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Int
forall a. Enum a =&gt; a -&gt; Int
</span><a href="GHC.Enum.html#fromEnum"><span class="hs-identifier hs-var">fromEnum</span></a></span><span> </span><span class="annot"><span class="annottext">(Bool -&gt; Int) -&gt; Bool -&gt; Int
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">FD -&gt; Bool
</span><a href="GHC.IO.FD.html#fdIsSocket"><span class="hs-identifier hs-var">fdIsSocket</span></a></span><span> </span><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679554902"><span class="hs-identifier hs-var">fd</span></a></span><span class="hs-special">)</span><span class="hs-cpp">
#else
</span><span>                          </span><span class="hs-number">0</span><span class="hs-cpp">
#endif
</span><span>  </span><span class="annot"><span class="annottext">Bool -&gt; IO Bool
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; Bool
forall a. Enum a =&gt; Int -&gt; a
</span><a href="GHC.Enum.html#toEnum"><span class="hs-identifier hs-var">toEnum</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CInt -&gt; Int
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679554899"><span class="hs-identifier hs-var">r</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-421"></span><span>
</span><span id="line-422"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="annot"><span class="hs-keyword">ccall</span></span><span> </span><span class="annot"><span class="hs-keyword">safe</span></span><span> </span><span class="annot"><span class="hs-string">&quot;fdReady&quot;</span></span><span>
</span><span id="line-423"></span><span>  </span><span id="fdReady"><span class="annot"><a href="GHC.IO.FD.html#fdReady"><span class="hs-identifier hs-var">fdReady</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Foreign.C.Types.html#CInt"><span class="hs-identifier hs-type">CInt</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Foreign.C.Types.html#CBool"><span class="hs-identifier hs-type">CBool</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Int.html#Int64"><span class="hs-identifier hs-type">Int64</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Foreign.C.Types.html#CBool"><span class="hs-identifier hs-type">CBool</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="Foreign.C.Types.html#CInt"><span class="hs-identifier hs-type">CInt</span></a></span><span>
</span><span id="line-424"></span><span>
</span><span id="line-425"></span><span class="hs-comment">-- ---------------------------------------------------------------------------</span><span>
</span><span id="line-426"></span><span class="hs-comment">-- Terminal-related stuff</span><span>
</span><span id="line-427"></span><span>
</span><span id="line-428"></span><span class="annot"><a href="GHC.IO.FD.html#isTerminal"><span class="hs-identifier hs-type">isTerminal</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.FD.html#FD"><span class="hs-identifier hs-type">FD</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Bool"><span class="hs-identifier hs-type">Bool</span></a></span><span>
</span><span id="line-429"></span><span id="isTerminal"><span class="annot"><span class="annottext">isTerminal :: FD -&gt; IO Bool
</span><a href="GHC.IO.FD.html#isTerminal"><span class="hs-identifier hs-var hs-var">isTerminal</span></a></span></span><span> </span><span id="local-6989586621679554896"><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679554896"><span class="hs-identifier hs-var">fd</span></a></span></span><span> </span><span class="hs-glyph">=</span><span class="hs-cpp">
#if defined(mingw32_HOST_OS)
</span><span>    </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">FD -&gt; Bool
</span><a href="GHC.IO.FD.html#fdIsSocket"><span class="hs-identifier hs-var">fdIsSocket</span></a></span><span> </span><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679554896"><span class="hs-identifier hs-var">fd</span></a></span><span> </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; IO Bool
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../ghc-prim/src/GHC.Types.html#False"><span class="hs-identifier hs-var">False</span></a></span><span>
</span><span id="line-432"></span><span>                     </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">CInt -&gt; IO CInt
</span><a href="System.Posix.Internals.html#is_console"><span class="hs-identifier hs-var">is_console</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FD -&gt; CInt
</span><a href="GHC.IO.FD.html#fdFD"><span class="hs-identifier hs-var hs-var">fdFD</span></a></span><span> </span><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679554896"><span class="hs-identifier hs-var">fd</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">IO CInt -&gt; (CInt -&gt; IO Bool) -&gt; IO Bool
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; (a -&gt; m b) -&gt; m b
</span><a href="GHC.Base.html#%3E%3E%3D"><span class="hs-operator hs-var">&gt;&gt;=</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; IO Bool
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span class="annot"><span class="annottext">(Bool -&gt; IO Bool) -&gt; (CInt -&gt; Bool) -&gt; CInt -&gt; IO Bool
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span class="annot"><span class="annottext">CInt -&gt; Bool
forall a. (Eq a, Num a) =&gt; a -&gt; Bool
</span><a href="Foreign.Marshal.Utils.html#toBool"><span class="hs-identifier hs-var">toBool</span></a></span><span class="hs-cpp">
#else
</span><span>    </span><span class="hs-identifier">c_isatty</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">fdFD</span><span> </span><span class="hs-identifier">fd</span><span class="hs-special">)</span><span> </span><span class="hs-operator">&gt;&gt;=</span><span> </span><span class="hs-identifier">return</span><span class="hs-operator">.</span><span class="hs-identifier">toBool</span><span class="hs-cpp">
#endif
</span><span>
</span><span id="line-437"></span><span class="annot"><a href="GHC.IO.FD.html#setEcho"><span class="hs-identifier hs-type">setEcho</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.FD.html#FD"><span class="hs-identifier hs-type">FD</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Bool"><span class="hs-identifier hs-type">Bool</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-438"></span><span id="setEcho"><span class="annot"><span class="annottext">setEcho :: FD -&gt; Bool -&gt; IO ()
</span><a href="GHC.IO.FD.html#setEcho"><span class="hs-identifier hs-var hs-var">setEcho</span></a></span></span><span> </span><span id="local-6989586621679554892"><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679554892"><span class="hs-identifier hs-var">fd</span></a></span></span><span> </span><span id="local-6989586621679554891"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679554891"><span class="hs-identifier hs-var">on</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CInt -&gt; Bool -&gt; IO ()
</span><a href="System.Posix.Internals.html#setEcho"><span class="hs-identifier hs-var">System.Posix.Internals.setEcho</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FD -&gt; CInt
</span><a href="GHC.IO.FD.html#fdFD"><span class="hs-identifier hs-var hs-var">fdFD</span></a></span><span> </span><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679554892"><span class="hs-identifier hs-var">fd</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679554891"><span class="hs-identifier hs-var">on</span></a></span><span>
</span><span id="line-439"></span><span>
</span><span id="line-440"></span><span class="annot"><a href="GHC.IO.FD.html#getEcho"><span class="hs-identifier hs-type">getEcho</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.FD.html#FD"><span class="hs-identifier hs-type">FD</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Bool"><span class="hs-identifier hs-type">Bool</span></a></span><span>
</span><span id="line-441"></span><span id="getEcho"><span class="annot"><span class="annottext">getEcho :: FD -&gt; IO Bool
</span><a href="GHC.IO.FD.html#getEcho"><span class="hs-identifier hs-var hs-var">getEcho</span></a></span></span><span> </span><span id="local-6989586621679554890"><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679554890"><span class="hs-identifier hs-var">fd</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CInt -&gt; IO Bool
</span><a href="System.Posix.Internals.html#getEcho"><span class="hs-identifier hs-var">System.Posix.Internals.getEcho</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FD -&gt; CInt
</span><a href="GHC.IO.FD.html#fdFD"><span class="hs-identifier hs-var hs-var">fdFD</span></a></span><span> </span><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679554890"><span class="hs-identifier hs-var">fd</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-442"></span><span>
</span><span id="line-443"></span><span class="annot"><a href="GHC.IO.FD.html#setRaw"><span class="hs-identifier hs-type">setRaw</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.FD.html#FD"><span class="hs-identifier hs-type">FD</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Bool"><span class="hs-identifier hs-type">Bool</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-444"></span><span id="setRaw"><span class="annot"><span class="annottext">setRaw :: FD -&gt; Bool -&gt; IO ()
</span><a href="GHC.IO.FD.html#setRaw"><span class="hs-identifier hs-var hs-var">setRaw</span></a></span></span><span> </span><span id="local-6989586621679554889"><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679554889"><span class="hs-identifier hs-var">fd</span></a></span></span><span> </span><span id="local-6989586621679554888"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679554888"><span class="hs-identifier hs-var">raw</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CInt -&gt; Bool -&gt; IO ()
</span><a href="System.Posix.Internals.html#setCooked"><span class="hs-identifier hs-var">System.Posix.Internals.setCooked</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FD -&gt; CInt
</span><a href="GHC.IO.FD.html#fdFD"><span class="hs-identifier hs-var hs-var">fdFD</span></a></span><span> </span><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679554889"><span class="hs-identifier hs-var">fd</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#not"><span class="hs-identifier hs-var">not</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679554888"><span class="hs-identifier hs-var">raw</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-445"></span><span>
</span><span id="line-446"></span><span class="hs-comment">-- -----------------------------------------------------------------------------</span><span>
</span><span id="line-447"></span><span class="hs-comment">-- Reading and Writing</span><span>
</span><span id="line-448"></span><span>
</span><span id="line-449"></span><span class="annot"><a href="GHC.IO.FD.html#fdRead"><span class="hs-identifier hs-type">fdRead</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.FD.html#FD"><span class="hs-identifier hs-type">FD</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Word.html#Word64"><span class="hs-identifier hs-type">Word64</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span>
</span><span id="line-450"></span><span id="fdRead"><span class="annot"><span class="annottext">fdRead :: FD -&gt; Ptr Word8 -&gt; Word64 -&gt; Int -&gt; IO Int
</span><a href="GHC.IO.FD.html#fdRead"><span class="hs-identifier hs-var hs-var">fdRead</span></a></span></span><span> </span><span id="local-6989586621679554886"><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679554886"><span class="hs-identifier hs-var">fd</span></a></span></span><span> </span><span id="local-6989586621679554885"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679554885"><span class="hs-identifier hs-var">ptr</span></a></span></span><span> </span><span id="local-6989586621679554884"><span class="annot"><span class="annottext">Word64
</span><a href="#local-6989586621679554884"><span class="hs-identifier hs-var">_offset</span></a></span></span><span> </span><span id="local-6989586621679554883"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679554883"><span class="hs-identifier hs-var">bytes</span></a></span></span><span>
</span><span id="line-451"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621679554882"><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679554882"><span class="hs-identifier hs-var">r</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">String -&gt; FD -&gt; Ptr Word8 -&gt; Int -&gt; CSize -&gt; IO CInt
</span><a href="GHC.IO.FD.html#readRawBufferPtr"><span class="hs-identifier hs-var">readRawBufferPtr</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;GHC.IO.FD.fdRead&quot;</span></span><span> </span><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679554886"><span class="hs-identifier hs-var">fd</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679554885"><span class="hs-identifier hs-var">ptr</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span>
</span><span id="line-452"></span><span>                </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; CSize
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">(Int -&gt; CSize) -&gt; Int -&gt; CSize
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int
</span><a href="GHC.IO.FD.html#clampReadSize"><span class="hs-identifier hs-var">clampReadSize</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679554883"><span class="hs-identifier hs-var">bytes</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-453"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Int -&gt; IO Int
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CInt -&gt; Int
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679554882"><span class="hs-identifier hs-var">r</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-454"></span><span>
</span><span id="line-455"></span><span class="annot"><a href="GHC.IO.FD.html#fdReadNonBlocking"><span class="hs-identifier hs-type">fdReadNonBlocking</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.FD.html#FD"><span class="hs-identifier hs-type">FD</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Word.html#Word64"><span class="hs-identifier hs-type">Word64</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-456"></span><span id="fdReadNonBlocking"><span class="annot"><span class="annottext">fdReadNonBlocking :: FD -&gt; Ptr Word8 -&gt; Word64 -&gt; Int -&gt; IO (Maybe Int)
</span><a href="GHC.IO.FD.html#fdReadNonBlocking"><span class="hs-identifier hs-var hs-var">fdReadNonBlocking</span></a></span></span><span> </span><span id="local-6989586621679554881"><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679554881"><span class="hs-identifier hs-var">fd</span></a></span></span><span> </span><span id="local-6989586621679554880"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679554880"><span class="hs-identifier hs-var">ptr</span></a></span></span><span> </span><span id="local-6989586621679554879"><span class="annot"><span class="annottext">Word64
</span><a href="#local-6989586621679554879"><span class="hs-identifier hs-var">_offset</span></a></span></span><span> </span><span id="local-6989586621679554878"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679554878"><span class="hs-identifier hs-var">bytes</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-457"></span><span>  </span><span id="local-6989586621679554877"><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679554877"><span class="hs-identifier hs-var">r</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">String -&gt; FD -&gt; Ptr Word8 -&gt; Int -&gt; CSize -&gt; IO CInt
</span><a href="GHC.IO.FD.html#readRawBufferPtrNoBlock"><span class="hs-identifier hs-var">readRawBufferPtrNoBlock</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;GHC.IO.FD.fdReadNonBlocking&quot;</span></span><span> </span><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679554881"><span class="hs-identifier hs-var">fd</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679554880"><span class="hs-identifier hs-var">ptr</span></a></span><span>
</span><span id="line-458"></span><span>           </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; CSize
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">(Int -&gt; CSize) -&gt; Int -&gt; CSize
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int
</span><a href="GHC.IO.FD.html#clampReadSize"><span class="hs-identifier hs-var">clampReadSize</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679554878"><span class="hs-identifier hs-var">bytes</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-459"></span><span>  </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">CInt -&gt; Int
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679554877"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-460"></span><span>    </span><span class="hs-special">(</span><span class="hs-glyph">-</span><span class="hs-number">1</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Maybe Int -&gt; IO (Maybe Int)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Maybe Int
forall a. Maybe a
</span><a href="GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-461"></span><span>    </span><span id="local-6989586621679554876"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679554876"><span class="hs-identifier hs-var">n</span></a></span></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Maybe Int -&gt; IO (Maybe Int)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; Maybe Int
forall a. a -&gt; Maybe a
</span><a href="GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679554876"><span class="hs-identifier hs-var">n</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-462"></span><span>
</span><span id="line-463"></span><span>
</span><span id="line-464"></span><span class="annot"><a href="GHC.IO.FD.html#fdWrite"><span class="hs-identifier hs-type">fdWrite</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.FD.html#FD"><span class="hs-identifier hs-type">FD</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Word.html#Word64"><span class="hs-identifier hs-type">Word64</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-465"></span><span id="fdWrite"><span class="annot"><span class="annottext">fdWrite :: FD -&gt; Ptr Word8 -&gt; Word64 -&gt; Int -&gt; IO ()
</span><a href="GHC.IO.FD.html#fdWrite"><span class="hs-identifier hs-var hs-var">fdWrite</span></a></span></span><span> </span><span id="local-6989586621679554875"><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679554875"><span class="hs-identifier hs-var">fd</span></a></span></span><span> </span><span id="local-6989586621679554874"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679554874"><span class="hs-identifier hs-var">ptr</span></a></span></span><span> </span><span id="local-6989586621679554873"><span class="annot"><span class="annottext">Word64
</span><a href="#local-6989586621679554873"><span class="hs-identifier hs-var">_offset</span></a></span></span><span> </span><span id="local-6989586621679554872"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679554872"><span class="hs-identifier hs-var">bytes</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-466"></span><span>  </span><span id="local-6989586621679554871"><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679554871"><span class="hs-identifier hs-var">res</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">String -&gt; FD -&gt; Ptr Word8 -&gt; Int -&gt; CSize -&gt; IO CInt
</span><a href="GHC.IO.FD.html#writeRawBufferPtr"><span class="hs-identifier hs-var">writeRawBufferPtr</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;GHC.IO.FD.fdWrite&quot;</span></span><span> </span><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679554875"><span class="hs-identifier hs-var">fd</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679554874"><span class="hs-identifier hs-var">ptr</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span>
</span><span id="line-467"></span><span>          </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; CSize
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">(Int -&gt; CSize) -&gt; Int -&gt; CSize
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int
</span><a href="GHC.IO.FD.html#clampWriteSize"><span class="hs-identifier hs-var">clampWriteSize</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679554872"><span class="hs-identifier hs-var">bytes</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-468"></span><span>  </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679554868"><span class="annot"><span class="annottext">res' :: Int
</span><a href="#local-6989586621679554868"><span class="hs-identifier hs-var hs-var">res'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CInt -&gt; Int
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679554871"><span class="hs-identifier hs-var">res</span></a></span><span>
</span><span id="line-469"></span><span>  </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679554868"><span class="hs-identifier hs-var">res'</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3C"><span class="hs-operator hs-var">&lt;</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679554872"><span class="hs-identifier hs-var">bytes</span></a></span><span>
</span><span id="line-470"></span><span>     </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">FD -&gt; Ptr Word8 -&gt; Word64 -&gt; Int -&gt; IO ()
</span><a href="GHC.IO.FD.html#fdWrite"><span class="hs-identifier hs-var">fdWrite</span></a></span><span> </span><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679554875"><span class="hs-identifier hs-var">fd</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679554874"><span class="hs-identifier hs-var">ptr</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Int -&gt; Ptr Word8
forall a b. Ptr a -&gt; Int -&gt; Ptr b
</span><a href="GHC.Ptr.html#plusPtr"><span class="hs-operator hs-var">`plusPtr`</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679554868"><span class="hs-identifier hs-var">res'</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Word64
</span><a href="#local-6989586621679554873"><span class="hs-identifier hs-var">_offset</span></a></span><span> </span><span class="annot"><span class="annottext">Word64 -&gt; Word64 -&gt; Word64
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Word64
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679554868"><span class="hs-identifier hs-var">res'</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679554872"><span class="hs-identifier hs-var">bytes</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679554868"><span class="hs-identifier hs-var">res'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-471"></span><span>     </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">() -&gt; IO ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-472"></span><span>
</span><span id="line-473"></span><span class="hs-comment">-- XXX ToDo: this isn't non-blocking</span><span>
</span><span id="line-474"></span><span class="annot"><a href="GHC.IO.FD.html#fdWriteNonBlocking"><span class="hs-identifier hs-type">fdWriteNonBlocking</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.FD.html#FD"><span class="hs-identifier hs-type">FD</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Word.html#Word64"><span class="hs-identifier hs-type">Word64</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span>
</span><span id="line-475"></span><span id="fdWriteNonBlocking"><span class="annot"><span class="annottext">fdWriteNonBlocking :: FD -&gt; Ptr Word8 -&gt; Word64 -&gt; Int -&gt; IO Int
</span><a href="GHC.IO.FD.html#fdWriteNonBlocking"><span class="hs-identifier hs-var hs-var">fdWriteNonBlocking</span></a></span></span><span> </span><span id="local-6989586621679554864"><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679554864"><span class="hs-identifier hs-var">fd</span></a></span></span><span> </span><span id="local-6989586621679554863"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679554863"><span class="hs-identifier hs-var">ptr</span></a></span></span><span> </span><span id="local-6989586621679554862"><span class="annot"><span class="annottext">Word64
</span><a href="#local-6989586621679554862"><span class="hs-identifier hs-var">_offset</span></a></span></span><span> </span><span id="local-6989586621679554861"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679554861"><span class="hs-identifier hs-var">bytes</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-476"></span><span>  </span><span id="local-6989586621679554860"><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679554860"><span class="hs-identifier hs-var">res</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">String -&gt; FD -&gt; Ptr Word8 -&gt; Int -&gt; CSize -&gt; IO CInt
</span><a href="GHC.IO.FD.html#writeRawBufferPtrNoBlock"><span class="hs-identifier hs-var">writeRawBufferPtrNoBlock</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;GHC.IO.FD.fdWriteNonBlocking&quot;</span></span><span> </span><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679554864"><span class="hs-identifier hs-var">fd</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679554863"><span class="hs-identifier hs-var">ptr</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span>
</span><span id="line-477"></span><span>            </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; CSize
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">(Int -&gt; CSize) -&gt; Int -&gt; CSize
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int
</span><a href="GHC.IO.FD.html#clampWriteSize"><span class="hs-identifier hs-var">clampWriteSize</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679554861"><span class="hs-identifier hs-var">bytes</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-478"></span><span>  </span><span class="annot"><span class="annottext">Int -&gt; IO Int
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CInt -&gt; Int
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679554860"><span class="hs-identifier hs-var">res</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-479"></span><span>
</span><span id="line-480"></span><span class="hs-comment">-- -----------------------------------------------------------------------------</span><span>
</span><span id="line-481"></span><span class="hs-comment">-- FD operations</span><span>
</span><span id="line-482"></span><span>
</span><span id="line-483"></span><span class="hs-comment">-- Low level routines for reading/writing to (raw)buffers:</span><span class="hs-cpp">

#if !defined(mingw32_HOST_OS)
</span><span>
</span><span id="line-487"></span><span class="hs-comment">{-
NOTE [nonblock]:

Unix has broken semantics when it comes to non-blocking I/O: you can
set the O_NONBLOCK flag on an FD, but it applies to the all other FDs
attached to the same underlying file, pipe or TTY; there's no way to
have private non-blocking behaviour for an FD.  See bug #724.

We fix this by only setting O_NONBLOCK on FDs that we create; FDs that
come from external sources or are exposed externally are left in
blocking mode.  This solution has some problems though.  We can't
completely simulate a non-blocking read without O_NONBLOCK: several
cases are wrong here.  The cases that are wrong:

  * reading/writing to a blocking FD in non-threaded mode.
    In threaded mode, we just make a safe call to read().
    In non-threaded mode we call select() before attempting to read,
    but that leaves a small race window where the data can be read
    from the file descriptor before we issue our blocking read().
  * readRawBufferNoBlock for a blocking FD

NOTE [2363]:

In the threaded RTS we could just make safe calls to read()/write()
for file descriptors in blocking mode without worrying about blocking
other threads, but the problem with this is that the thread will be
uninterruptible while it is blocked in the foreign call.  See #2363.
So now we always call fdReady() before reading, and if fdReady
indicates that there's no data, we call threadWaitRead.

-}</span><span>
</span><span id="line-518"></span><span>
</span><span id="line-519"></span><span class="hs-identifier">readRawBufferPtr</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">String</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">FD</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Ptr</span><span> </span><span class="hs-identifier">Word8</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Int</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">CSize</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">Int</span><span>
</span><span id="line-520"></span><span class="hs-identifier">readRawBufferPtr</span><span> </span><span class="hs-identifier">loc</span><span> </span><span class="hs-glyph">!</span><span class="hs-identifier">fd</span><span> </span><span class="hs-glyph">!</span><span class="hs-identifier">buf</span><span> </span><span class="hs-glyph">!</span><span class="hs-identifier">off</span><span> </span><span class="hs-glyph">!</span><span class="hs-identifier">len</span><span>
</span><span id="line-521"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="hs-identifier">isNonBlocking</span><span> </span><span class="hs-identifier">fd</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">unsafe_read</span><span> </span><span class="hs-comment">-- unsafe is ok, it can't block</span><span>
</span><span id="line-522"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="hs-identifier">otherwise</span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-identifier">r</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-identifier">throwErrnoIfMinus1</span><span> </span><span class="hs-identifier">loc</span><span>
</span><span id="line-523"></span><span>                                </span><span class="hs-special">(</span><span class="hs-identifier">unsafe_fdReady</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">fdFD</span><span> </span><span class="hs-identifier">fd</span><span class="hs-special">)</span><span> </span><span class="hs-number">0</span><span> </span><span class="hs-number">0</span><span> </span><span class="hs-number">0</span><span class="hs-special">)</span><span>
</span><span id="line-524"></span><span>                      </span><span class="hs-keyword">if</span><span> </span><span class="hs-identifier">r</span><span> </span><span class="hs-operator">/=</span><span> </span><span class="hs-number">0</span><span>
</span><span id="line-525"></span><span>                        </span><span class="hs-keyword">then</span><span> </span><span class="hs-identifier">read</span><span>
</span><span id="line-526"></span><span>                        </span><span class="hs-keyword">else</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-identifier">threadWaitRead</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">fromIntegral</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">fdFD</span><span> </span><span class="hs-identifier">fd</span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">;</span><span> </span><span class="hs-identifier">read</span><span>
</span><span id="line-527"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-528"></span><span>    </span><span class="hs-identifier">do_read</span><span> </span><span class="hs-identifier">call</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">fromIntegral</span><span> </span><span class="hs-special">`</span><span class="hs-identifier">fmap</span><span class="hs-special">`</span><span>
</span><span id="line-529"></span><span>                      </span><span class="hs-identifier">throwErrnoIfMinus1RetryMayBlock</span><span> </span><span class="hs-identifier">loc</span><span> </span><span class="hs-identifier">call</span><span>
</span><span id="line-530"></span><span>                            </span><span class="hs-special">(</span><span class="hs-identifier">threadWaitRead</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">fromIntegral</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">fdFD</span><span> </span><span class="hs-identifier">fd</span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-531"></span><span>    </span><span class="hs-identifier">read</span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="hs-identifier">threaded</span><span> </span><span class="hs-keyword">then</span><span> </span><span class="hs-identifier">safe_read</span><span> </span><span class="hs-keyword">else</span><span> </span><span class="hs-identifier">unsafe_read</span><span>
</span><span id="line-532"></span><span>    </span><span class="hs-identifier">unsafe_read</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">do_read</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">c_read</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">fdFD</span><span> </span><span class="hs-identifier">fd</span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">buf</span><span> </span><span class="hs-special">`</span><span class="hs-identifier">plusPtr</span><span class="hs-special">`</span><span> </span><span class="hs-identifier">off</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">len</span><span class="hs-special">)</span><span>
</span><span id="line-533"></span><span>    </span><span class="hs-identifier">safe_read</span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">do_read</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">c_safe_read</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">fdFD</span><span> </span><span class="hs-identifier">fd</span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">buf</span><span> </span><span class="hs-special">`</span><span class="hs-identifier">plusPtr</span><span class="hs-special">`</span><span> </span><span class="hs-identifier">off</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">len</span><span class="hs-special">)</span><span>
</span><span id="line-534"></span><span>
</span><span id="line-535"></span><span class="hs-comment">-- return: -1 indicates EOF, &gt;=0 is bytes read</span><span>
</span><span id="line-536"></span><span class="hs-identifier">readRawBufferPtrNoBlock</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">String</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">FD</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Ptr</span><span> </span><span class="hs-identifier">Word8</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Int</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">CSize</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">Int</span><span>
</span><span id="line-537"></span><span class="hs-identifier">readRawBufferPtrNoBlock</span><span> </span><span class="hs-identifier">loc</span><span> </span><span class="hs-glyph">!</span><span class="hs-identifier">fd</span><span> </span><span class="hs-glyph">!</span><span class="hs-identifier">buf</span><span> </span><span class="hs-glyph">!</span><span class="hs-identifier">off</span><span> </span><span class="hs-glyph">!</span><span class="hs-identifier">len</span><span>
</span><span id="line-538"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="hs-identifier">isNonBlocking</span><span> </span><span class="hs-identifier">fd</span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">unsafe_read</span><span> </span><span class="hs-comment">-- unsafe is ok, it can't block</span><span>
</span><span id="line-539"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="hs-identifier">otherwise</span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-identifier">r</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-identifier">unsafe_fdReady</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">fdFD</span><span> </span><span class="hs-identifier">fd</span><span class="hs-special">)</span><span> </span><span class="hs-number">0</span><span> </span><span class="hs-number">0</span><span> </span><span class="hs-number">0</span><span>
</span><span id="line-540"></span><span>                      </span><span class="hs-keyword">if</span><span> </span><span class="hs-identifier">r</span><span> </span><span class="hs-operator">/=</span><span> </span><span class="hs-number">0</span><span> </span><span class="hs-keyword">then</span><span> </span><span class="hs-identifier">safe_read</span><span>
</span><span id="line-541"></span><span>                                </span><span class="hs-keyword">else</span><span> </span><span class="hs-identifier">return</span><span> </span><span class="hs-number">0</span><span>
</span><span id="line-542"></span><span>       </span><span class="hs-comment">-- XXX see note [nonblock]</span><span>
</span><span id="line-543"></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-544"></span><span>   </span><span class="hs-identifier">do_read</span><span> </span><span class="hs-identifier">call</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-identifier">r</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-identifier">throwErrnoIfMinus1RetryOnBlock</span><span> </span><span class="hs-identifier">loc</span><span> </span><span class="hs-identifier">call</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">return</span><span> </span><span class="hs-special">(</span><span class="hs-glyph">-</span><span class="hs-number">1</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-545"></span><span>                     </span><span class="hs-keyword">case</span><span> </span><span class="hs-identifier">r</span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-546"></span><span>                       </span><span class="hs-special">(</span><span class="hs-glyph">-</span><span class="hs-number">1</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">return</span><span> </span><span class="hs-number">0</span><span>
</span><span id="line-547"></span><span>                       </span><span class="hs-number">0</span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">return</span><span> </span><span class="hs-special">(</span><span class="hs-glyph">-</span><span class="hs-number">1</span><span class="hs-special">)</span><span>
</span><span id="line-548"></span><span>                       </span><span class="hs-identifier">n</span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">return</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">fromIntegral</span><span> </span><span class="hs-identifier">n</span><span class="hs-special">)</span><span>
</span><span id="line-549"></span><span>   </span><span class="hs-identifier">unsafe_read</span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">do_read</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">c_read</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">fdFD</span><span> </span><span class="hs-identifier">fd</span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">buf</span><span> </span><span class="hs-special">`</span><span class="hs-identifier">plusPtr</span><span class="hs-special">`</span><span> </span><span class="hs-identifier">off</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">len</span><span class="hs-special">)</span><span>
</span><span id="line-550"></span><span>   </span><span class="hs-identifier">safe_read</span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">do_read</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">c_safe_read</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">fdFD</span><span> </span><span class="hs-identifier">fd</span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">buf</span><span> </span><span class="hs-special">`</span><span class="hs-identifier">plusPtr</span><span class="hs-special">`</span><span> </span><span class="hs-identifier">off</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">len</span><span class="hs-special">)</span><span>
</span><span id="line-551"></span><span>
</span><span id="line-552"></span><span class="hs-identifier">writeRawBufferPtr</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">String</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">FD</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Ptr</span><span> </span><span class="hs-identifier">Word8</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Int</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">CSize</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">CInt</span><span>
</span><span id="line-553"></span><span class="hs-identifier">writeRawBufferPtr</span><span> </span><span class="hs-identifier">loc</span><span> </span><span class="hs-glyph">!</span><span class="hs-identifier">fd</span><span> </span><span class="hs-glyph">!</span><span class="hs-identifier">buf</span><span> </span><span class="hs-glyph">!</span><span class="hs-identifier">off</span><span> </span><span class="hs-glyph">!</span><span class="hs-identifier">len</span><span>
</span><span id="line-554"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="hs-identifier">isNonBlocking</span><span> </span><span class="hs-identifier">fd</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">unsafe_write</span><span> </span><span class="hs-comment">-- unsafe is ok, it can't block</span><span>
</span><span id="line-555"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="hs-identifier">otherwise</span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-identifier">r</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-identifier">unsafe_fdReady</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">fdFD</span><span> </span><span class="hs-identifier">fd</span><span class="hs-special">)</span><span> </span><span class="hs-number">1</span><span> </span><span class="hs-number">0</span><span> </span><span class="hs-number">0</span><span>
</span><span id="line-556"></span><span>                     </span><span class="hs-keyword">if</span><span> </span><span class="hs-identifier">r</span><span> </span><span class="hs-operator">/=</span><span> </span><span class="hs-number">0</span><span>
</span><span id="line-557"></span><span>                        </span><span class="hs-keyword">then</span><span> </span><span class="hs-identifier">write</span><span>
</span><span id="line-558"></span><span>                        </span><span class="hs-keyword">else</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-identifier">threadWaitWrite</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">fromIntegral</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">fdFD</span><span> </span><span class="hs-identifier">fd</span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">;</span><span> </span><span class="hs-identifier">write</span><span>
</span><span id="line-559"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-560"></span><span>    </span><span class="hs-identifier">do_write</span><span> </span><span class="hs-identifier">call</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">fromIntegral</span><span> </span><span class="hs-special">`</span><span class="hs-identifier">fmap</span><span class="hs-special">`</span><span>
</span><span id="line-561"></span><span>                      </span><span class="hs-identifier">throwErrnoIfMinus1RetryMayBlock</span><span> </span><span class="hs-identifier">loc</span><span> </span><span class="hs-identifier">call</span><span>
</span><span id="line-562"></span><span>                        </span><span class="hs-special">(</span><span class="hs-identifier">threadWaitWrite</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">fromIntegral</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">fdFD</span><span> </span><span class="hs-identifier">fd</span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-563"></span><span>    </span><span class="hs-identifier">write</span><span>         </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="hs-identifier">threaded</span><span> </span><span class="hs-keyword">then</span><span> </span><span class="hs-identifier">safe_write</span><span> </span><span class="hs-keyword">else</span><span> </span><span class="hs-identifier">unsafe_write</span><span>
</span><span id="line-564"></span><span>    </span><span class="hs-identifier">unsafe_write</span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">do_write</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">c_write</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">fdFD</span><span> </span><span class="hs-identifier">fd</span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">buf</span><span> </span><span class="hs-special">`</span><span class="hs-identifier">plusPtr</span><span class="hs-special">`</span><span> </span><span class="hs-identifier">off</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">len</span><span class="hs-special">)</span><span>
</span><span id="line-565"></span><span>    </span><span class="hs-identifier">safe_write</span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">do_write</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">c_safe_write</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">fdFD</span><span> </span><span class="hs-identifier">fd</span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">buf</span><span> </span><span class="hs-special">`</span><span class="hs-identifier">plusPtr</span><span class="hs-special">`</span><span> </span><span class="hs-identifier">off</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">len</span><span class="hs-special">)</span><span>
</span><span id="line-566"></span><span>
</span><span id="line-567"></span><span class="hs-identifier">writeRawBufferPtrNoBlock</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">String</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">FD</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Ptr</span><span> </span><span class="hs-identifier">Word8</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Int</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">CSize</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">CInt</span><span>
</span><span id="line-568"></span><span class="hs-identifier">writeRawBufferPtrNoBlock</span><span> </span><span class="hs-identifier">loc</span><span> </span><span class="hs-glyph">!</span><span class="hs-identifier">fd</span><span> </span><span class="hs-glyph">!</span><span class="hs-identifier">buf</span><span> </span><span class="hs-glyph">!</span><span class="hs-identifier">off</span><span> </span><span class="hs-glyph">!</span><span class="hs-identifier">len</span><span>
</span><span id="line-569"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="hs-identifier">isNonBlocking</span><span> </span><span class="hs-identifier">fd</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">unsafe_write</span><span> </span><span class="hs-comment">-- unsafe is ok, it can't block</span><span>
</span><span id="line-570"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="hs-identifier">otherwise</span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-identifier">r</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-identifier">unsafe_fdReady</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">fdFD</span><span> </span><span class="hs-identifier">fd</span><span class="hs-special">)</span><span> </span><span class="hs-number">1</span><span> </span><span class="hs-number">0</span><span> </span><span class="hs-number">0</span><span>
</span><span id="line-571"></span><span>                     </span><span class="hs-keyword">if</span><span> </span><span class="hs-identifier">r</span><span> </span><span class="hs-operator">/=</span><span> </span><span class="hs-number">0</span><span> </span><span class="hs-keyword">then</span><span> </span><span class="hs-identifier">write</span><span>
</span><span id="line-572"></span><span>                               </span><span class="hs-keyword">else</span><span> </span><span class="hs-identifier">return</span><span> </span><span class="hs-number">0</span><span>
</span><span id="line-573"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-574"></span><span>    </span><span class="hs-identifier">do_write</span><span> </span><span class="hs-identifier">call</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-identifier">r</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-identifier">throwErrnoIfMinus1RetryOnBlock</span><span> </span><span class="hs-identifier">loc</span><span> </span><span class="hs-identifier">call</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">return</span><span> </span><span class="hs-special">(</span><span class="hs-glyph">-</span><span class="hs-number">1</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-575"></span><span>                       </span><span class="hs-keyword">case</span><span> </span><span class="hs-identifier">r</span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-576"></span><span>                         </span><span class="hs-special">(</span><span class="hs-glyph">-</span><span class="hs-number">1</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">return</span><span> </span><span class="hs-number">0</span><span>
</span><span id="line-577"></span><span>                         </span><span class="hs-identifier">n</span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">return</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">fromIntegral</span><span> </span><span class="hs-identifier">n</span><span class="hs-special">)</span><span>
</span><span id="line-578"></span><span>    </span><span class="hs-identifier">write</span><span>         </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="hs-identifier">threaded</span><span> </span><span class="hs-keyword">then</span><span> </span><span class="hs-identifier">safe_write</span><span> </span><span class="hs-keyword">else</span><span> </span><span class="hs-identifier">unsafe_write</span><span>
</span><span id="line-579"></span><span>    </span><span class="hs-identifier">unsafe_write</span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">do_write</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">c_write</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">fdFD</span><span> </span><span class="hs-identifier">fd</span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">buf</span><span> </span><span class="hs-special">`</span><span class="hs-identifier">plusPtr</span><span class="hs-special">`</span><span> </span><span class="hs-identifier">off</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">len</span><span class="hs-special">)</span><span>
</span><span id="line-580"></span><span>    </span><span class="hs-identifier">safe_write</span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">do_write</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">c_safe_write</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">fdFD</span><span> </span><span class="hs-identifier">fd</span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">buf</span><span> </span><span class="hs-special">`</span><span class="hs-identifier">plusPtr</span><span class="hs-special">`</span><span> </span><span class="hs-identifier">off</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">len</span><span class="hs-special">)</span><span>
</span><span id="line-581"></span><span>
</span><span id="line-582"></span><span class="hs-identifier">isNonBlocking</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">FD</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Bool</span><span>
</span><span id="line-583"></span><span class="hs-identifier">isNonBlocking</span><span> </span><span class="hs-identifier">fd</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">fdIsNonBlocking</span><span> </span><span class="hs-identifier">fd</span><span> </span><span class="hs-operator">/=</span><span> </span><span class="hs-number">0</span><span>
</span><span id="line-584"></span><span>
</span><span id="line-585"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">ccall</span><span> </span><span class="hs-keyword">unsafe</span><span> </span><span class="hs-string">&quot;fdReady&quot;</span><span>
</span><span id="line-586"></span><span>  </span><span class="hs-identifier">unsafe_fdReady</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">CInt</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">CBool</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Int64</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">CBool</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">CInt</span><span class="hs-cpp">

#else /* mingw32_HOST_OS.... */
</span><span>
</span><span id="line-590"></span><span class="annot"><a href="GHC.IO.FD.html#readRawBufferPtr"><span class="hs-identifier hs-type">readRawBufferPtr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.IO.FD.html#FD"><span class="hs-identifier hs-type">FD</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Foreign.C.Types.html#CSize"><span class="hs-identifier hs-type">CSize</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="Foreign.C.Types.html#CInt"><span class="hs-identifier hs-type">CInt</span></a></span><span>
</span><span id="line-591"></span><span id="readRawBufferPtr"><span class="annot"><span class="annottext">readRawBufferPtr :: String -&gt; FD -&gt; Ptr Word8 -&gt; Int -&gt; CSize -&gt; IO CInt
</span><a href="GHC.IO.FD.html#readRawBufferPtr"><span class="hs-identifier hs-var hs-var">readRawBufferPtr</span></a></span></span><span> </span><span id="local-6989586621679554858"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679554858"><span class="hs-identifier hs-var">loc</span></a></span></span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621679554857"><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679554857"><span class="hs-identifier hs-var">fd</span></a></span></span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621679554856"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679554856"><span class="hs-identifier hs-var">buf</span></a></span></span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621679554855"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679554855"><span class="hs-identifier hs-var">off</span></a></span></span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621679554854"><span class="annot"><span class="annottext">CSize
</span><a href="#local-6989586621679554854"><span class="hs-identifier hs-var">len</span></a></span></span><span>
</span><span id="line-592"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="GHC.IO.FD.html#threaded"><span class="hs-identifier hs-var">threaded</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; FD -&gt; Ptr Word8 -&gt; Int -&gt; CSize -&gt; IO CInt
</span><a href="GHC.IO.FD.html#blockingReadRawBufferPtr"><span class="hs-identifier hs-var">blockingReadRawBufferPtr</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679554858"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679554857"><span class="hs-identifier hs-var">fd</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679554856"><span class="hs-identifier hs-var">buf</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679554855"><span class="hs-identifier hs-var">off</span></a></span><span> </span><span class="annot"><span class="annottext">CSize
</span><a href="#local-6989586621679554854"><span class="hs-identifier hs-var">len</span></a></span><span>
</span><span id="line-593"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; FD -&gt; Ptr Word8 -&gt; Int -&gt; CSize -&gt; IO CInt
</span><a href="GHC.IO.FD.html#asyncReadRawBufferPtr"><span class="hs-identifier hs-var">asyncReadRawBufferPtr</span></a></span><span>    </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679554858"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679554857"><span class="hs-identifier hs-var">fd</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679554856"><span class="hs-identifier hs-var">buf</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679554855"><span class="hs-identifier hs-var">off</span></a></span><span> </span><span class="annot"><span class="annottext">CSize
</span><a href="#local-6989586621679554854"><span class="hs-identifier hs-var">len</span></a></span><span>
</span><span id="line-594"></span><span>
</span><span id="line-595"></span><span class="annot"><a href="GHC.IO.FD.html#writeRawBufferPtr"><span class="hs-identifier hs-type">writeRawBufferPtr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.IO.FD.html#FD"><span class="hs-identifier hs-type">FD</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Foreign.C.Types.html#CSize"><span class="hs-identifier hs-type">CSize</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="Foreign.C.Types.html#CInt"><span class="hs-identifier hs-type">CInt</span></a></span><span>
</span><span id="line-596"></span><span id="writeRawBufferPtr"><span class="annot"><span class="annottext">writeRawBufferPtr :: String -&gt; FD -&gt; Ptr Word8 -&gt; Int -&gt; CSize -&gt; IO CInt
</span><a href="GHC.IO.FD.html#writeRawBufferPtr"><span class="hs-identifier hs-var hs-var">writeRawBufferPtr</span></a></span></span><span> </span><span id="local-6989586621679554850"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679554850"><span class="hs-identifier hs-var">loc</span></a></span></span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621679554849"><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679554849"><span class="hs-identifier hs-var">fd</span></a></span></span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621679554848"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679554848"><span class="hs-identifier hs-var">buf</span></a></span></span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621679554847"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679554847"><span class="hs-identifier hs-var">off</span></a></span></span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621679554846"><span class="annot"><span class="annottext">CSize
</span><a href="#local-6989586621679554846"><span class="hs-identifier hs-var">len</span></a></span></span><span>
</span><span id="line-597"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="GHC.IO.FD.html#threaded"><span class="hs-identifier hs-var">threaded</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; FD -&gt; Ptr Word8 -&gt; Int -&gt; CSize -&gt; IO CInt
</span><a href="GHC.IO.FD.html#blockingWriteRawBufferPtr"><span class="hs-identifier hs-var">blockingWriteRawBufferPtr</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679554850"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679554849"><span class="hs-identifier hs-var">fd</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679554848"><span class="hs-identifier hs-var">buf</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679554847"><span class="hs-identifier hs-var">off</span></a></span><span> </span><span class="annot"><span class="annottext">CSize
</span><a href="#local-6989586621679554846"><span class="hs-identifier hs-var">len</span></a></span><span>
</span><span id="line-598"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; FD -&gt; Ptr Word8 -&gt; Int -&gt; CSize -&gt; IO CInt
</span><a href="GHC.IO.FD.html#asyncWriteRawBufferPtr"><span class="hs-identifier hs-var">asyncWriteRawBufferPtr</span></a></span><span>    </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679554850"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679554849"><span class="hs-identifier hs-var">fd</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679554848"><span class="hs-identifier hs-var">buf</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679554847"><span class="hs-identifier hs-var">off</span></a></span><span> </span><span class="annot"><span class="annottext">CSize
</span><a href="#local-6989586621679554846"><span class="hs-identifier hs-var">len</span></a></span><span>
</span><span id="line-599"></span><span>
</span><span id="line-600"></span><span class="annot"><a href="GHC.IO.FD.html#readRawBufferPtrNoBlock"><span class="hs-identifier hs-type">readRawBufferPtrNoBlock</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.IO.FD.html#FD"><span class="hs-identifier hs-type">FD</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Foreign.C.Types.html#CSize"><span class="hs-identifier hs-type">CSize</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="Foreign.C.Types.html#CInt"><span class="hs-identifier hs-type">CInt</span></a></span><span>
</span><span id="line-601"></span><span id="readRawBufferPtrNoBlock"><span class="annot"><span class="annottext">readRawBufferPtrNoBlock :: String -&gt; FD -&gt; Ptr Word8 -&gt; Int -&gt; CSize -&gt; IO CInt
</span><a href="GHC.IO.FD.html#readRawBufferPtrNoBlock"><span class="hs-identifier hs-var hs-var">readRawBufferPtrNoBlock</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; FD -&gt; Ptr Word8 -&gt; Int -&gt; CSize -&gt; IO CInt
</span><a href="GHC.IO.FD.html#readRawBufferPtr"><span class="hs-identifier hs-var">readRawBufferPtr</span></a></span><span>
</span><span id="line-602"></span><span>
</span><span id="line-603"></span><span class="annot"><a href="GHC.IO.FD.html#writeRawBufferPtrNoBlock"><span class="hs-identifier hs-type">writeRawBufferPtrNoBlock</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.IO.FD.html#FD"><span class="hs-identifier hs-type">FD</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Foreign.C.Types.html#CSize"><span class="hs-identifier hs-type">CSize</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="Foreign.C.Types.html#CInt"><span class="hs-identifier hs-type">CInt</span></a></span><span>
</span><span id="line-604"></span><span id="writeRawBufferPtrNoBlock"><span class="annot"><span class="annottext">writeRawBufferPtrNoBlock :: String -&gt; FD -&gt; Ptr Word8 -&gt; Int -&gt; CSize -&gt; IO CInt
</span><a href="GHC.IO.FD.html#writeRawBufferPtrNoBlock"><span class="hs-identifier hs-var hs-var">writeRawBufferPtrNoBlock</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; FD -&gt; Ptr Word8 -&gt; Int -&gt; CSize -&gt; IO CInt
</span><a href="GHC.IO.FD.html#writeRawBufferPtr"><span class="hs-identifier hs-var">writeRawBufferPtr</span></a></span><span>
</span><span id="line-605"></span><span>
</span><span id="line-606"></span><span class="hs-comment">-- Async versions of the read/write primitives, for the non-threaded RTS</span><span>
</span><span id="line-607"></span><span>
</span><span id="line-608"></span><span class="annot"><a href="GHC.IO.FD.html#asyncReadRawBufferPtr"><span class="hs-identifier hs-type">asyncReadRawBufferPtr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.IO.FD.html#FD"><span class="hs-identifier hs-type">FD</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Foreign.C.Types.html#CSize"><span class="hs-identifier hs-type">CSize</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="Foreign.C.Types.html#CInt"><span class="hs-identifier hs-type">CInt</span></a></span><span>
</span><span id="line-609"></span><span id="asyncReadRawBufferPtr"><span class="annot"><span class="annottext">asyncReadRawBufferPtr :: String -&gt; FD -&gt; Ptr Word8 -&gt; Int -&gt; CSize -&gt; IO CInt
</span><a href="GHC.IO.FD.html#asyncReadRawBufferPtr"><span class="hs-identifier hs-var hs-var">asyncReadRawBufferPtr</span></a></span></span><span> </span><span id="local-6989586621679554843"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679554843"><span class="hs-identifier hs-var">loc</span></a></span></span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621679554842"><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679554842"><span class="hs-identifier hs-var">fd</span></a></span></span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621679554841"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679554841"><span class="hs-identifier hs-var">buf</span></a></span></span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621679554840"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679554840"><span class="hs-identifier hs-var">off</span></a></span></span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621679554839"><span class="annot"><span class="annottext">CSize
</span><a href="#local-6989586621679554839"><span class="hs-identifier hs-var">len</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-610"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621679554838"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679554838"><span class="hs-identifier hs-var">l</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679554837"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679554837"><span class="hs-identifier hs-var">rc</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int -&gt; Ptr Any -&gt; IO (Int, Int)
forall a. Int -&gt; Int -&gt; Int -&gt; Ptr a -&gt; IO (Int, Int)
</span><a href="GHC.Conc.Windows.html#asyncRead"><span class="hs-identifier hs-var">asyncRead</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CInt -&gt; Int
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FD -&gt; CInt
</span><a href="GHC.IO.FD.html#fdFD"><span class="hs-identifier hs-var hs-var">fdFD</span></a></span><span> </span><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679554842"><span class="hs-identifier hs-var">fd</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FD -&gt; Int
</span><a href="GHC.IO.FD.html#fdIsSocket_"><span class="hs-identifier hs-var hs-var">fdIsSocket_</span></a></span><span> </span><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679554842"><span class="hs-identifier hs-var">fd</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-611"></span><span>                        </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CSize -&gt; Int
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">CSize
</span><a href="#local-6989586621679554839"><span class="hs-identifier hs-var">len</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679554841"><span class="hs-identifier hs-var">buf</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Int -&gt; Ptr Any
forall a b. Ptr a -&gt; Int -&gt; Ptr b
</span><a href="GHC.Ptr.html#plusPtr"><span class="hs-operator hs-var">`plusPtr`</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679554840"><span class="hs-identifier hs-var">off</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-612"></span><span>    </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679554838"><span class="hs-identifier hs-var">l</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3D%3D"><span class="hs-operator hs-var">==</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">-</span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span>
</span><span id="line-613"></span><span>      </span><span class="hs-keyword">then</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679554832"><span class="annot"><span class="annottext">sock_errno :: Errno
</span><a href="#local-6989586621679554832"><span class="hs-identifier hs-var hs-var">sock_errno</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ErrCode -&gt; Errno
</span><a href="GHC.Windows.html#c_maperrno_func"><span class="hs-identifier hs-var">c_maperrno_func</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; ErrCode
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679554837"><span class="hs-identifier hs-var">rc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-614"></span><span>               </span><span id="local-6989586621679554828"><span class="annot"><span class="annottext">non_sock_errno :: Errno
</span><a href="#local-6989586621679554828"><span class="hs-identifier hs-var hs-var">non_sock_errno</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CInt -&gt; Errno
</span><a href="Foreign.C.Error.html#Errno"><span class="hs-identifier hs-var">Errno</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; CInt
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679554837"><span class="hs-identifier hs-var">rc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-615"></span><span>               </span><span id="local-6989586621679554826"><span class="annot"><span class="annottext">errno :: Errno
</span><a href="#local-6989586621679554826"><span class="hs-identifier hs-var hs-var">errno</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Errno -&gt; Errno -&gt; Bool -&gt; Errno
forall a. a -&gt; a -&gt; Bool -&gt; a
</span><a href="Data.Bool.html#bool"><span class="hs-identifier hs-var">bool</span></a></span><span> </span><span class="annot"><span class="annottext">Errno
</span><a href="#local-6989586621679554828"><span class="hs-identifier hs-var">non_sock_errno</span></a></span><span> </span><span class="annot"><span class="annottext">Errno
</span><a href="#local-6989586621679554832"><span class="hs-identifier hs-var">sock_errno</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FD -&gt; Bool
</span><a href="GHC.IO.FD.html#fdIsSocket"><span class="hs-identifier hs-var">fdIsSocket</span></a></span><span> </span><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679554842"><span class="hs-identifier hs-var">fd</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-616"></span><span>           </span><span class="hs-keyword">in</span><span>  </span><span class="annot"><span class="annottext">IOException -&gt; IO CInt
forall a. IOException -&gt; IO a
</span><a href="GHC.IO.Exception.html#ioError"><span class="hs-identifier hs-var">ioError</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; Errno -&gt; Maybe Handle -&gt; Maybe String -&gt; IOException
</span><a href="Foreign.C.Error.html#errnoToIOError"><span class="hs-identifier hs-var">errnoToIOError</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679554843"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="annot"><span class="annottext">Errno
</span><a href="#local-6989586621679554826"><span class="hs-identifier hs-var">errno</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Handle
forall a. Maybe a
</span><a href="GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe String
forall a. Maybe a
</span><a href="GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-617"></span><span>      </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">CInt -&gt; IO CInt
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; CInt
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679554838"><span class="hs-identifier hs-var">l</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-618"></span><span>
</span><span id="line-619"></span><span class="annot"><a href="GHC.IO.FD.html#asyncWriteRawBufferPtr"><span class="hs-identifier hs-type">asyncWriteRawBufferPtr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.IO.FD.html#FD"><span class="hs-identifier hs-type">FD</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Foreign.C.Types.html#CSize"><span class="hs-identifier hs-type">CSize</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="Foreign.C.Types.html#CInt"><span class="hs-identifier hs-type">CInt</span></a></span><span>
</span><span id="line-620"></span><span id="asyncWriteRawBufferPtr"><span class="annot"><span class="annottext">asyncWriteRawBufferPtr :: String -&gt; FD -&gt; Ptr Word8 -&gt; Int -&gt; CSize -&gt; IO CInt
</span><a href="GHC.IO.FD.html#asyncWriteRawBufferPtr"><span class="hs-identifier hs-var hs-var">asyncWriteRawBufferPtr</span></a></span></span><span> </span><span id="local-6989586621679554822"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679554822"><span class="hs-identifier hs-var">loc</span></a></span></span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621679554821"><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679554821"><span class="hs-identifier hs-var">fd</span></a></span></span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621679554820"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679554820"><span class="hs-identifier hs-var">buf</span></a></span></span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621679554819"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679554819"><span class="hs-identifier hs-var">off</span></a></span></span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621679554818"><span class="annot"><span class="annottext">CSize
</span><a href="#local-6989586621679554818"><span class="hs-identifier hs-var">len</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-621"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621679554817"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679554817"><span class="hs-identifier hs-var">l</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679554816"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679554816"><span class="hs-identifier hs-var">rc</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int -&gt; Ptr Any -&gt; IO (Int, Int)
forall a. Int -&gt; Int -&gt; Int -&gt; Ptr a -&gt; IO (Int, Int)
</span><a href="GHC.Conc.Windows.html#asyncWrite"><span class="hs-identifier hs-var">asyncWrite</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CInt -&gt; Int
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FD -&gt; CInt
</span><a href="GHC.IO.FD.html#fdFD"><span class="hs-identifier hs-var hs-var">fdFD</span></a></span><span> </span><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679554821"><span class="hs-identifier hs-var">fd</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FD -&gt; Int
</span><a href="GHC.IO.FD.html#fdIsSocket_"><span class="hs-identifier hs-var hs-var">fdIsSocket_</span></a></span><span> </span><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679554821"><span class="hs-identifier hs-var">fd</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-622"></span><span>                  </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CSize -&gt; Int
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">CSize
</span><a href="#local-6989586621679554818"><span class="hs-identifier hs-var">len</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679554820"><span class="hs-identifier hs-var">buf</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Int -&gt; Ptr Any
forall a b. Ptr a -&gt; Int -&gt; Ptr b
</span><a href="GHC.Ptr.html#plusPtr"><span class="hs-operator hs-var">`plusPtr`</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679554819"><span class="hs-identifier hs-var">off</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-623"></span><span>    </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679554817"><span class="hs-identifier hs-var">l</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3D%3D"><span class="hs-operator hs-var">==</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">-</span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span>
</span><span id="line-624"></span><span>      </span><span class="hs-keyword">then</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679554812"><span class="annot"><span class="annottext">sock_errno :: Errno
</span><a href="#local-6989586621679554812"><span class="hs-identifier hs-var hs-var">sock_errno</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ErrCode -&gt; Errno
</span><a href="GHC.Windows.html#c_maperrno_func"><span class="hs-identifier hs-var">c_maperrno_func</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; ErrCode
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679554816"><span class="hs-identifier hs-var">rc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-625"></span><span>               </span><span id="local-6989586621679554809"><span class="annot"><span class="annottext">non_sock_errno :: Errno
</span><a href="#local-6989586621679554809"><span class="hs-identifier hs-var hs-var">non_sock_errno</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CInt -&gt; Errno
</span><a href="Foreign.C.Error.html#Errno"><span class="hs-identifier hs-var">Errno</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; CInt
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679554816"><span class="hs-identifier hs-var">rc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-626"></span><span>               </span><span id="local-6989586621679554808"><span class="annot"><span class="annottext">errno :: Errno
</span><a href="#local-6989586621679554808"><span class="hs-identifier hs-var hs-var">errno</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Errno -&gt; Errno -&gt; Bool -&gt; Errno
forall a. a -&gt; a -&gt; Bool -&gt; a
</span><a href="Data.Bool.html#bool"><span class="hs-identifier hs-var">bool</span></a></span><span> </span><span class="annot"><span class="annottext">Errno
</span><a href="#local-6989586621679554809"><span class="hs-identifier hs-var">non_sock_errno</span></a></span><span> </span><span class="annot"><span class="annottext">Errno
</span><a href="#local-6989586621679554812"><span class="hs-identifier hs-var">sock_errno</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FD -&gt; Bool
</span><a href="GHC.IO.FD.html#fdIsSocket"><span class="hs-identifier hs-var">fdIsSocket</span></a></span><span> </span><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679554821"><span class="hs-identifier hs-var">fd</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-627"></span><span>           </span><span class="hs-keyword">in</span><span>  </span><span class="annot"><span class="annottext">IOException -&gt; IO CInt
forall a. IOException -&gt; IO a
</span><a href="GHC.IO.Exception.html#ioError"><span class="hs-identifier hs-var">ioError</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; Errno -&gt; Maybe Handle -&gt; Maybe String -&gt; IOException
</span><a href="Foreign.C.Error.html#errnoToIOError"><span class="hs-identifier hs-var">errnoToIOError</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679554822"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="annot"><span class="annottext">Errno
</span><a href="#local-6989586621679554808"><span class="hs-identifier hs-var">errno</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Handle
forall a. Maybe a
</span><a href="GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe String
forall a. Maybe a
</span><a href="GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-628"></span><span>      </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">CInt -&gt; IO CInt
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; CInt
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679554817"><span class="hs-identifier hs-var">l</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-629"></span><span>
</span><span id="line-630"></span><span class="hs-comment">-- Blocking versions of the read/write primitives, for the threaded RTS</span><span>
</span><span id="line-631"></span><span>
</span><span id="line-632"></span><span class="annot"><a href="GHC.IO.FD.html#blockingReadRawBufferPtr"><span class="hs-identifier hs-type">blockingReadRawBufferPtr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.IO.FD.html#FD"><span class="hs-identifier hs-type">FD</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Foreign.C.Types.html#CSize"><span class="hs-identifier hs-type">CSize</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="Foreign.C.Types.html#CInt"><span class="hs-identifier hs-type">CInt</span></a></span><span>
</span><span id="line-633"></span><span id="blockingReadRawBufferPtr"><span class="annot"><span class="annottext">blockingReadRawBufferPtr :: String -&gt; FD -&gt; Ptr Word8 -&gt; Int -&gt; CSize -&gt; IO CInt
</span><a href="GHC.IO.FD.html#blockingReadRawBufferPtr"><span class="hs-identifier hs-var hs-var">blockingReadRawBufferPtr</span></a></span></span><span> </span><span id="local-6989586621679554807"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679554807"><span class="hs-identifier hs-var">loc</span></a></span></span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621679554806"><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679554806"><span class="hs-identifier hs-var">fd</span></a></span></span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621679554805"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679554805"><span class="hs-identifier hs-var">buf</span></a></span></span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621679554804"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679554804"><span class="hs-identifier hs-var">off</span></a></span></span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621679554803"><span class="annot"><span class="annottext">CSize
</span><a href="#local-6989586621679554803"><span class="hs-identifier hs-var">len</span></a></span></span><span>
</span><span id="line-634"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; IO CInt -&gt; IO CInt
forall a. (Eq a, Num a) =&gt; String -&gt; IO a -&gt; IO a
</span><a href="Foreign.C.Error.html#throwErrnoIfMinus1Retry"><span class="hs-identifier hs-var">throwErrnoIfMinus1Retry</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679554807"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="annot"><span class="annottext">(IO CInt -&gt; IO CInt) -&gt; IO CInt -&gt; IO CInt
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-635"></span><span>        </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679554802"><span class="annot"><span class="annottext">start_ptr :: Ptr b
</span><a href="#local-6989586621679554802"><span class="hs-identifier hs-var hs-var">start_ptr</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679554805"><span class="hs-identifier hs-var">buf</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Int -&gt; Ptr b
forall a b. Ptr a -&gt; Int -&gt; Ptr b
</span><a href="GHC.Ptr.html#plusPtr"><span class="hs-operator hs-var">`plusPtr`</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679554804"><span class="hs-identifier hs-var">off</span></a></span><span>
</span><span id="line-636"></span><span>            </span><span id="local-6989586621679554798"><span class="annot"><span class="annottext">recv_ret :: IO CInt
</span><a href="#local-6989586621679554798"><span class="hs-identifier hs-var hs-var">recv_ret</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CInt -&gt; Ptr Word8 -&gt; CInt -&gt; CInt -&gt; IO CInt
</span><a href="GHC.IO.FD.html#c_safe_recv"><span class="hs-identifier hs-var">c_safe_recv</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FD -&gt; CInt
</span><a href="GHC.IO.FD.html#fdFD"><span class="hs-identifier hs-var hs-var">fdFD</span></a></span><span> </span><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679554806"><span class="hs-identifier hs-var">fd</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Ptr Word8
forall {b}. Ptr b
</span><a href="#local-6989586621679554802"><span class="hs-identifier hs-var">start_ptr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CSize -&gt; CInt
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">CSize
</span><a href="#local-6989586621679554803"><span class="hs-identifier hs-var">len</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CInt
</span><span class="hs-number">0</span></span><span>
</span><span id="line-637"></span><span>            </span><span id="local-6989586621679554793"><span class="annot"><span class="annottext">read_ret :: IO CInt
</span><a href="#local-6989586621679554793"><span class="hs-identifier hs-var hs-var">read_ret</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CInt -&gt; Ptr Word8 -&gt; CUInt -&gt; IO CInt
</span><a href="System.Posix.Internals.html#c_safe_read"><span class="hs-identifier hs-var">c_safe_read</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FD -&gt; CInt
</span><a href="GHC.IO.FD.html#fdFD"><span class="hs-identifier hs-var hs-var">fdFD</span></a></span><span> </span><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679554806"><span class="hs-identifier hs-var">fd</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Ptr Word8
forall {b}. Ptr b
</span><a href="#local-6989586621679554802"><span class="hs-identifier hs-var">start_ptr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CSize -&gt; CUInt
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">CSize
</span><a href="#local-6989586621679554803"><span class="hs-identifier hs-var">len</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-638"></span><span>        </span><span id="local-6989586621679554791"><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679554791"><span class="hs-identifier hs-var">r</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IO CInt -&gt; IO CInt -&gt; Bool -&gt; IO CInt
forall a. a -&gt; a -&gt; Bool -&gt; a
</span><a href="Data.Bool.html#bool"><span class="hs-identifier hs-var">bool</span></a></span><span> </span><span class="annot"><span class="annottext">IO CInt
</span><a href="#local-6989586621679554793"><span class="hs-identifier hs-var">read_ret</span></a></span><span> </span><span class="annot"><span class="annottext">IO CInt
</span><a href="#local-6989586621679554798"><span class="hs-identifier hs-var">recv_ret</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FD -&gt; Bool
</span><a href="GHC.IO.FD.html#fdIsSocket"><span class="hs-identifier hs-var">fdIsSocket</span></a></span><span> </span><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679554806"><span class="hs-identifier hs-var">fd</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-639"></span><span>        </span><span class="annot"><span class="annottext">Bool -&gt; IO () -&gt; IO ()
forall (f :: * -&gt; *). Applicative f =&gt; Bool -&gt; f () -&gt; f ()
</span><a href="GHC.Base.html#when"><span class="hs-identifier hs-var">when</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><span class="annottext">FD -&gt; Bool
</span><a href="GHC.IO.FD.html#fdIsSocket"><span class="hs-identifier hs-var">fdIsSocket</span></a></span><span> </span><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679554806"><span class="hs-identifier hs-var">fd</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%26%26"><span class="hs-operator hs-var">&amp;&amp;</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679554791"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="annot"><span class="annottext">CInt -&gt; CInt -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3D%3D"><span class="hs-operator hs-var">==</span></a></span><span> </span><span class="hs-glyph">-</span><span class="annot"><span class="annottext">CInt
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">IO ()
</span><a href="GHC.Windows.html#c_maperrno"><span class="hs-identifier hs-var">c_maperrno</span></a></span><span>
</span><span id="line-640"></span><span>        </span><span class="annot"><span class="annottext">CInt -&gt; IO CInt
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679554791"><span class="hs-identifier hs-var">r</span></a></span><span>
</span><span id="line-641"></span><span>      </span><span class="hs-comment">-- We trust read() to give us the correct errno but recv(), as a</span><span>
</span><span id="line-642"></span><span>      </span><span class="hs-comment">-- Winsock function, doesn't do the errno conversion so if the fd</span><span>
</span><span id="line-643"></span><span>      </span><span class="hs-comment">-- is for a socket, we do it from GetLastError() ourselves.</span><span>
</span><span id="line-644"></span><span>
</span><span id="line-645"></span><span class="annot"><a href="GHC.IO.FD.html#blockingWriteRawBufferPtr"><span class="hs-identifier hs-type">blockingWriteRawBufferPtr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.IO.FD.html#FD"><span class="hs-identifier hs-type">FD</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Foreign.C.Types.html#CSize"><span class="hs-identifier hs-type">CSize</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="Foreign.C.Types.html#CInt"><span class="hs-identifier hs-type">CInt</span></a></span><span>
</span><span id="line-646"></span><span id="blockingWriteRawBufferPtr"><span class="annot"><span class="annottext">blockingWriteRawBufferPtr :: String -&gt; FD -&gt; Ptr Word8 -&gt; Int -&gt; CSize -&gt; IO CInt
</span><a href="GHC.IO.FD.html#blockingWriteRawBufferPtr"><span class="hs-identifier hs-var hs-var">blockingWriteRawBufferPtr</span></a></span></span><span> </span><span id="local-6989586621679554789"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679554789"><span class="hs-identifier hs-var">loc</span></a></span></span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621679554788"><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679554788"><span class="hs-identifier hs-var">fd</span></a></span></span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621679554787"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679554787"><span class="hs-identifier hs-var">buf</span></a></span></span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621679554786"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679554786"><span class="hs-identifier hs-var">off</span></a></span></span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621679554785"><span class="annot"><span class="annottext">CSize
</span><a href="#local-6989586621679554785"><span class="hs-identifier hs-var">len</span></a></span></span><span>
</span><span id="line-647"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; IO CInt -&gt; IO CInt
forall a. (Eq a, Num a) =&gt; String -&gt; IO a -&gt; IO a
</span><a href="Foreign.C.Error.html#throwErrnoIfMinus1Retry"><span class="hs-identifier hs-var">throwErrnoIfMinus1Retry</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679554789"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="annot"><span class="annottext">(IO CInt -&gt; IO CInt) -&gt; IO CInt -&gt; IO CInt
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-648"></span><span>        </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679554784"><span class="annot"><span class="annottext">start_ptr :: Ptr b
</span><a href="#local-6989586621679554784"><span class="hs-identifier hs-var hs-var">start_ptr</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679554787"><span class="hs-identifier hs-var">buf</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Int -&gt; Ptr b
forall a b. Ptr a -&gt; Int -&gt; Ptr b
</span><a href="GHC.Ptr.html#plusPtr"><span class="hs-operator hs-var">`plusPtr`</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679554786"><span class="hs-identifier hs-var">off</span></a></span><span>
</span><span id="line-649"></span><span>            </span><span id="local-6989586621679554780"><span class="annot"><span class="annottext">send_ret :: IO CInt
</span><a href="#local-6989586621679554780"><span class="hs-identifier hs-var hs-var">send_ret</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CInt -&gt; Ptr Word8 -&gt; CInt -&gt; CInt -&gt; IO CInt
</span><a href="GHC.IO.FD.html#c_safe_send"><span class="hs-identifier hs-var">c_safe_send</span></a></span><span>  </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FD -&gt; CInt
</span><a href="GHC.IO.FD.html#fdFD"><span class="hs-identifier hs-var hs-var">fdFD</span></a></span><span> </span><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679554788"><span class="hs-identifier hs-var">fd</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Ptr Word8
forall {b}. Ptr b
</span><a href="#local-6989586621679554784"><span class="hs-identifier hs-var">start_ptr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CSize -&gt; CInt
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">CSize
</span><a href="#local-6989586621679554785"><span class="hs-identifier hs-var">len</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CInt
</span><span class="hs-number">0</span></span><span>
</span><span id="line-650"></span><span>            </span><span id="local-6989586621679554776"><span class="annot"><span class="annottext">write_ret :: IO CInt
</span><a href="#local-6989586621679554776"><span class="hs-identifier hs-var hs-var">write_ret</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CInt -&gt; Ptr Word8 -&gt; CUInt -&gt; IO CInt
</span><a href="System.Posix.Internals.html#c_safe_write"><span class="hs-identifier hs-var">c_safe_write</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FD -&gt; CInt
</span><a href="GHC.IO.FD.html#fdFD"><span class="hs-identifier hs-var hs-var">fdFD</span></a></span><span> </span><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679554788"><span class="hs-identifier hs-var">fd</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Ptr Word8
forall {b}. Ptr b
</span><a href="#local-6989586621679554784"><span class="hs-identifier hs-var">start_ptr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CSize -&gt; CUInt
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">CSize
</span><a href="#local-6989586621679554785"><span class="hs-identifier hs-var">len</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-651"></span><span>        </span><span id="local-6989586621679554774"><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679554774"><span class="hs-identifier hs-var">r</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IO CInt -&gt; IO CInt -&gt; Bool -&gt; IO CInt
forall a. a -&gt; a -&gt; Bool -&gt; a
</span><a href="Data.Bool.html#bool"><span class="hs-identifier hs-var">bool</span></a></span><span> </span><span class="annot"><span class="annottext">IO CInt
</span><a href="#local-6989586621679554776"><span class="hs-identifier hs-var">write_ret</span></a></span><span> </span><span class="annot"><span class="annottext">IO CInt
</span><a href="#local-6989586621679554780"><span class="hs-identifier hs-var">send_ret</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FD -&gt; Bool
</span><a href="GHC.IO.FD.html#fdIsSocket"><span class="hs-identifier hs-var">fdIsSocket</span></a></span><span> </span><span class="annot"><span class="annottext">FD
</span><a href="#local-6989586621679554788"><span class="hs-identifier hs-var">fd</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-652"></span><span>        </span><span class="annot"><span class="annottext">Bool -&gt; IO () -&gt; IO ()
forall (f :: * -&gt; *). Applicative f =&gt; Bool -&gt; f () -&gt; f ()
</span><a href="GHC.Base.html#when"><span class="hs-identifier hs-var">when</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679554774"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="annot"><span class="annottext">CInt -&gt; CInt -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3D%3D"><span class="hs-operator hs-var">==</span></a></span><span> </span><span class="hs-glyph">-</span><span class="annot"><span class="annottext">CInt
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">IO ()
</span><a href="GHC.Windows.html#c_maperrno"><span class="hs-identifier hs-var">c_maperrno</span></a></span><span>
</span><span id="line-653"></span><span>        </span><span class="annot"><span class="annottext">CInt -&gt; IO CInt
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679554774"><span class="hs-identifier hs-var">r</span></a></span><span>
</span><span id="line-654"></span><span>      </span><span class="hs-comment">-- We don't trust write() to give us the correct errno, and</span><span>
</span><span id="line-655"></span><span>      </span><span class="hs-comment">-- instead do the errno conversion from GetLastError()</span><span>
</span><span id="line-656"></span><span>      </span><span class="hs-comment">-- ourselves. The main reason is that we treat ERROR_NO_DATA</span><span>
</span><span id="line-657"></span><span>      </span><span class="hs-comment">-- (pipe is closing) as EPIPE, whereas write() returns EINVAL</span><span>
</span><span id="line-658"></span><span>      </span><span class="hs-comment">-- for this case. We need to detect EPIPE correctly, because it</span><span>
</span><span id="line-659"></span><span>      </span><span class="hs-comment">-- shouldn't be reported as an error when it happens on stdout.</span><span>
</span><span id="line-660"></span><span>      </span><span class="hs-comment">-- As for send()'s case, Winsock functions don't do errno</span><span>
</span><span id="line-661"></span><span>      </span><span class="hs-comment">-- conversion in any case so we have to do it ourselves.</span><span>
</span><span id="line-662"></span><span>      </span><span class="hs-comment">-- That means we're doing the errno conversion no matter if the</span><span>
</span><span id="line-663"></span><span>      </span><span class="hs-comment">-- fd is from a socket or not.</span><span>
</span><span id="line-664"></span><span>
</span><span id="line-665"></span><span class="hs-comment">-- NOTE: &quot;safe&quot; versions of the read/write calls for use by the threaded RTS.</span><span>
</span><span id="line-666"></span><span class="hs-comment">-- These calls may block, but that's ok.</span><span>
</span><span id="line-667"></span><span>
</span><span id="line-668"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-keyword">safe</span><span> </span><span class="hs-string">&quot;recv&quot;</span><span>
</span><span id="line-669"></span><span>   </span><span id="c_safe_recv"><span class="annot"><a href="GHC.IO.FD.html#c_safe_recv"><span class="hs-identifier hs-var">c_safe_recv</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Foreign.C.Types.html#CInt"><span class="hs-identifier hs-type">CInt</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Foreign.C.Types.html#CInt"><span class="hs-identifier hs-type">CInt</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Foreign.C.Types.html#CInt"><span class="hs-identifier hs-type">CInt</span></a></span><span class="hs-comment">{-flags-}</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="Foreign.C.Types.html#CInt"><span class="hs-identifier hs-type">CInt</span></a></span><span>
</span><span id="line-670"></span><span>
</span><span id="line-671"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-keyword">safe</span><span> </span><span class="hs-string">&quot;send&quot;</span><span>
</span><span id="line-672"></span><span>   </span><span id="c_safe_send"><span class="annot"><a href="GHC.IO.FD.html#c_safe_send"><span class="hs-identifier hs-var">c_safe_send</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Foreign.C.Types.html#CInt"><span class="hs-identifier hs-type">CInt</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Foreign.C.Types.html#CInt"><span class="hs-identifier hs-type">CInt</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Foreign.C.Types.html#CInt"><span class="hs-identifier hs-type">CInt</span></a></span><span class="hs-comment">{-flags-}</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="Foreign.C.Types.html#CInt"><span class="hs-identifier hs-type">CInt</span></a></span><span class="hs-cpp">

#endif
</span><span>
</span><span id="line-676"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="annot"><span class="hs-keyword">ccall</span></span><span> </span><span class="annot"><span class="hs-keyword">unsafe</span></span><span> </span><span class="annot"><span class="hs-string">&quot;rtsSupportsBoundThreads&quot;</span></span><span> </span><span id="threaded"><span class="annot"><a href="GHC.IO.FD.html#threaded"><span class="hs-identifier hs-var">threaded</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Bool"><span class="hs-identifier hs-type">Bool</span></a></span><span>
</span><span id="line-677"></span><span>
</span><span id="line-678"></span><span class="hs-comment">-- -----------------------------------------------------------------------------</span><span>
</span><span id="line-679"></span><span class="hs-comment">-- utils</span><span class="hs-cpp">

#if !defined(mingw32_HOST_OS)
</span><span class="hs-identifier">throwErrnoIfMinus1RetryOnBlock</span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">String</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">CSsize</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">CSsize</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">CSsize</span><span>
</span><span id="line-683"></span><span class="hs-identifier">throwErrnoIfMinus1RetryOnBlock</span><span> </span><span class="hs-identifier">loc</span><span> </span><span class="hs-identifier">f</span><span> </span><span class="hs-identifier">on_block</span><span>  </span><span class="hs-glyph">=</span><span>
</span><span id="line-684"></span><span>  </span><span class="hs-keyword">do</span><span>
</span><span id="line-685"></span><span>    </span><span class="hs-identifier">res</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-identifier">f</span><span>
</span><span id="line-686"></span><span>    </span><span class="hs-keyword">if</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">res</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">CSsize</span><span class="hs-special">)</span><span> </span><span class="hs-operator">==</span><span> </span><span class="hs-glyph">-</span><span class="hs-number">1</span><span>
</span><span id="line-687"></span><span>      </span><span class="hs-keyword">then</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-688"></span><span>        </span><span class="hs-identifier">err</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-identifier">getErrno</span><span>
</span><span id="line-689"></span><span>        </span><span class="hs-keyword">if</span><span> </span><span class="hs-identifier">err</span><span> </span><span class="hs-operator">==</span><span> </span><span class="hs-identifier">eINTR</span><span>
</span><span id="line-690"></span><span>          </span><span class="hs-keyword">then</span><span> </span><span class="hs-identifier">throwErrnoIfMinus1RetryOnBlock</span><span> </span><span class="hs-identifier">loc</span><span> </span><span class="hs-identifier">f</span><span> </span><span class="hs-identifier">on_block</span><span>
</span><span id="line-691"></span><span>          </span><span class="hs-keyword">else</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="hs-identifier">err</span><span> </span><span class="hs-operator">==</span><span> </span><span class="hs-identifier">eWOULDBLOCK</span><span> </span><span class="hs-operator">||</span><span> </span><span class="hs-identifier">err</span><span> </span><span class="hs-operator">==</span><span> </span><span class="hs-identifier">eAGAIN</span><span>
</span><span id="line-692"></span><span>                 </span><span class="hs-keyword">then</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-identifier">on_block</span><span>
</span><span id="line-693"></span><span>                 </span><span class="hs-keyword">else</span><span> </span><span class="hs-identifier">throwErrno</span><span> </span><span class="hs-identifier">loc</span><span>
</span><span id="line-694"></span><span>      </span><span class="hs-keyword">else</span><span> </span><span class="hs-identifier">return</span><span> </span><span class="hs-identifier">res</span><span class="hs-cpp">
#endif
</span><span>
</span><span id="line-697"></span><span class="hs-comment">-- -----------------------------------------------------------------------------</span><span>
</span><span id="line-698"></span><span class="hs-comment">-- Locking/unlocking</span><span>
</span><span id="line-699"></span><span>
</span><span id="line-700"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="annot"><span class="hs-keyword">ccall</span></span><span> </span><span class="annot"><span class="hs-keyword">unsafe</span></span><span> </span><span class="annot"><span class="hs-string">&quot;lockFile&quot;</span></span><span>
</span><span id="line-701"></span><span>  </span><span id="lockFile"><span class="annot"><a href="GHC.IO.FD.html#lockFile"><span class="hs-identifier hs-var">lockFile</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Word.html#Word64"><span class="hs-identifier hs-type">Word64</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Word.html#Word64"><span class="hs-identifier hs-type">Word64</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Word.html#Word64"><span class="hs-identifier hs-type">Word64</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Foreign.C.Types.html#CInt"><span class="hs-identifier hs-type">CInt</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="Foreign.C.Types.html#CInt"><span class="hs-identifier hs-type">CInt</span></a></span><span>
</span><span id="line-702"></span><span>
</span><span id="line-703"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="annot"><span class="hs-keyword">ccall</span></span><span> </span><span class="annot"><span class="hs-keyword">unsafe</span></span><span> </span><span class="annot"><span class="hs-string">&quot;unlockFile&quot;</span></span><span>
</span><span id="line-704"></span><span>  </span><span id="unlockFile"><span class="annot"><a href="GHC.IO.FD.html#unlockFile"><span class="hs-identifier hs-var">unlockFile</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Word.html#Word64"><span class="hs-identifier hs-type">Word64</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="Foreign.C.Types.html#CInt"><span class="hs-identifier hs-type">CInt</span></a></span><span class="hs-cpp">

#if defined(mingw32_HOST_OS)
</span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="annot"><span class="hs-keyword">ccall</span></span><span> </span><span class="annot"><span class="hs-keyword">unsafe</span></span><span> </span><span class="annot"><span class="hs-string">&quot;get_unique_file_info&quot;</span></span><span>
</span><span id="line-708"></span><span>  </span><span id="c_getUniqueFileInfo"><span class="annot"><a href="GHC.IO.FD.html#c_getUniqueFileInfo"><span class="hs-identifier hs-var">c_getUniqueFileInfo</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Foreign.C.Types.html#CInt"><span class="hs-identifier hs-type">CInt</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="GHC.Word.html#Word64"><span class="hs-identifier hs-type">Word64</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="GHC.Word.html#Word64"><span class="hs-identifier hs-type">Word64</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span class="hs-cpp">
#endif
</span></pre></body></html>